renderImage: width and height

1,617 views
Skip to first unread message

Sigbert Klinke

unread,
Jul 19, 2014, 3:12:36 PM7/19/14
to shiny-...@googlegroups.com
Hi,

I use in ui.R in the mainPanel

imageOutput
("door1")

and define in server,R

    list(src = paste0('www/', outfile),
         contentType
= 'image/png',
         width
=86,
         height
=233,
         alt
= sprintf("Door %i", i))

But however I set width and height, in the HTML page I get

<div id="door1" class="shiny-image-output" style="width: 100% ; height: 400px">
 
What is going on?

Thanks Sigbert

Yihui Xie

unread,
Jul 21, 2014, 4:15:31 PM7/21/14
to Sigbert Klinke, shiny-discuss
I think you need imageOutput('door1', width = 86, height = 233). See
?shiny::imageOutput

Regards,
Yihui

Sigbert Klinke

unread,
Jul 22, 2014, 3:01:53 AM7/22/14
to shiny-...@googlegroups.com, sig...@wiwi.hu-berlin.de
Hi,

you are right, thanks a lot. But still the outer div looks like

<div id="door2" class="shiny-image-output shiny-bound-output" style="width: 100% ; height: 400px">
<img width="86" height="233" src="data:image/png;base64,..." alt="Door 2">
</div>


How can I influence the height?

Sigbert 

Yihui Xie

unread,
Jul 25, 2014, 4:20:33 PM7/25/14
to Sigbert Klinke, shiny-discuss
Sorry, but I cannot reproduce the problem with the latest CRAN version of shiny:

library(shiny)
runApp(list(
ui = fluidPage(imageOutput('foo', width = 200, height = 100)),
server = function(input, output) {
output$foo = renderImage({
f = tempfile(fileext = '.png')
png(f, width = 400, height = 200)
plot(cars)
dev.off()
list(src = f)
})
}
))

This gives me <div id="foo" class="shiny-image-output" style="width:
200px ; height: 100px"></div> as expected.

> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] shiny_0.10.0

loaded via a namespace (and not attached):
[1] bitops_1.0-6 caTools_1.17 digest_0.6.4 htmltools_0.2.4
[5] httpuv_1.3.0 Rcpp_0.11.2 RJSONIO_1.2-0.2 tools_3.1.1
[9] xtable_1.7-3

Regards,
Yihui


On Tue, Jul 22, 2014 at 2:01 AM, Sigbert Klinke
<sig...@wiwi.hu-berlin.de> wrote:
> Hi,
>
Reply all
Reply to author
Forward
0 new messages