Skip to content
Back to formatted view

Raw Message

Message-ID: <CALgZk2EL3mkdcNPsiAdHRYMEnOJXa6YzKJWFjQctuNn10O9Jyg@mail.gmail.com>
Date: 2012-05-14T21:21:03Z
From: Ethan Brown
Subject: determine size (width and height) of a graphics file via R - how?
In-Reply-To: <D8B948E4-15FA-499A-9A49-0018703368E2@gmx.de>

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:
> Hi,
>
> is there a way to determine the size (width, height) of a graphics file saved on my hard disk, e.g. a .bmp, via R.
> What I want is basically the same information on the dimensions of the graphic file that I get from my file browser.
>
> Thanks
> Mark
>
> PS. Why: I use the R2PPT and I need to determine the size of the original graphic before adding it to a slide.
>
> ??????????????????
> Mark Heckmann
> Blog: www.markheckmann.de
> R-Blog: http://ryouready.wordpress.com
>
>
>
>
>
>
>
>
>
>
>
> ? ? ? ?[[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>