Forum: Ruby on Rails Determining width and height of image files

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
William LeFevre (Guest)
on 2006-01-29 09:54
I'm trying to figure out how to determine the width and height of images
that are uploaded through my app. Either from the posted data or the
file I save to disk. I've been searching around for info but no luck;
I'm completely at a loss. Any suggestions or pointers would be great.

Project background:
The site is an artists portfolio site. The images are thumbnails and
large pictures of her paintings. Rather then force her type in the width
and height for every image I'd like to be able to detect those
programmatically.

- William
Bob S. (Guest)
on 2006-01-29 11:12
(Received via mailing list)
This will help you out. Just gotta parse out what you need.

http://www.bigbold.com/snippets/tag/rmagick

Google is your friend.

Bob S.
http://www.railtie.net/
William L. (Guest)
on 2006-01-29 20:00
That example requires rmagick. Is there a way to do this without extra
modules?

Thanks for the link. I found it once before, forgot to bookmark it, and
was never able to find it again. From what I've seen, it looks like a
good site.
Alex Y. (Guest)
on 2006-01-29 20:22
(Received via mailing list)
William LeFevre wrote:
> That example requires rmagick. Is there a way to do this without extra
> modules?
>
Not unless you want to write your own code to parse the information out
of the image files...  It's not too hard for most common file types, but
it'd be far easier to get RMagick working, because that'll give you a
way in to automatically generating thumbnails from originals, and so on.

--
Alex
William L. (Guest)
on 2006-01-29 20:27
> Not unless you want to write your own code to parse the information out
> of the image files...

That's what I'm after. Right now I don't need all image processing
capabilities; I just need the width and height.
Fabien (Guest)
on 2006-01-29 20:37
(Received via mailing list)
Try this: http://www.bigbold.com/snippets/posts/show/805

It doesn't depend on rmagick; it parses the file headers instead.
William L. (Guest)
on 2006-01-29 21:05
Sweet. That looks perfect. I'll dig into that tonight.
Ezra Z. (Guest)
on 2006-01-30 03:31
(Received via mailing list)
On Jan 29, 2006, at 10:00 AM, William LeFevre wrote:

> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


  Try this:

http://www.bigbold.com/snippets/posts/show/805

Cheers-
-Ezra Z.
WebMaster
Yakima Herald-Republic Newspaper
removed_email_address@domain.invalid
509-577-7732
Steve R. (Guest)
on 2006-01-30 08:31
(Received via mailing list)
Looking at this code, doesn't it assume a certain "endian-ness"?
This topic is locked and can not be replied to.