Skip to content

determine size (width and height) of a graphics file via R - how?

2 messages · Mark Heckmann, Ethan Brown

1 day later
#
Hi Mark,

You can do this easily with the "identify" command in ImageMagick
<http://www.imagemagick.org>. Install it, and then from within an R
session:

system2("identify", "yourimagename.jpg")

...and it should give you something like this:

yourimagename.jpg JPEG 800x533 800x533+0+0 8-bit DirectClass 378KB
0.000u 0:00.019

...which is overkill but does include the dimensions.

If you're on Windows you need an extra argument:

system2("identify", "yourimagename.jpg", invisible = FALSE)

to make sure it actually shows you the result.

EBImage is an R interface to imagemagick but is probably more trouble
than it's worth for the simple task you're trying to do.

Hope this helps,
Ethan
On Sun, May 13, 2012 at 6:57 AM, Mark Heckmann <mark.heckmann at gmx.de> wrote: