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 -- Posted via http://www.ruby-forum.com/.
This will help you out. Just gotta parse out what you need. http://www.bigbold.com/snippets/tag/rmagick Google is your friend. Bob Silva http://www.railtie.net/> -----Original Message----- > From: rails-bounces@lists.rubyonrails.org [mailto:rails- > bounces@lists.rubyonrails.org] On Behalf Of William LeFevre > Sent: Saturday, January 28, 2006 11:55 PM > To: rails@lists.rubyonrails.org > Subject: [Rails] Determining width and height of image files > > 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 > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
William LeFevre
2006-Jan-29 18:00 UTC
[Rails] Re: RE: Determining width and height of image files
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. -- Posted via http://www.ruby-forum.com/.
Alex Young
2006-Jan-29 18:22 UTC
[Rails] Re: RE: Determining width and height of image files
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 LeFevre
2006-Jan-29 18:28 UTC
[Rails] Re: Re: RE: Determining width and height of image files
> 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. -- Posted via http://www.ruby-forum.com/.
Try this: http://www.bigbold.com/snippets/posts/show/805 It doesn''t depend on rmagick; it parses the file headers instead.> > > > 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. >
William LeFevre
2006-Jan-29 19:05 UTC
[Rails] Re: Determining width and height of image files
Sweet. That looks perfect. I''ll dig into that tonight. -- Posted via http://www.ruby-forum.com/.
Ezra Zygmuntowicz
2006-Jan-30 01:28 UTC
[Rails] Re: RE: Determining width and height of image files
On Jan 29, 2006, at 10:00 AM, William LeFevre wrote:> 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. > > -- > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >Try this: http://www.bigbold.com/snippets/posts/show/805 Cheers- -Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra@yakima-herald.com 509-577-7732
Steve Ross
2006-Jan-30 06:30 UTC
[Rails] Re: RE: Determining width and height of image files
Looking at this code, doesn''t it assume a certain "endian-ness"? On 1/29/06 5:29 PM, "Ezra Zygmuntowicz" <ezra@yakimaherald.com> wrote:> > On Jan 29, 2006, at 10:00 AM, William LeFevre wrote: > >> 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. >> >> -- >> >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > > Try this: > > http://www.bigbold.com/snippets/posts/show/805 > > Cheers- > -Ezra Zygmuntowicz > WebMaster > Yakima Herald-Republic Newspaper > ezra@yakima-herald.com > 509-577-7732 >