StringIO to Tempfile?

Personally, I'm not sure that's the best way to go about it.
I'd just use the rmagick interface.
http://rmagick.rubyforge.org/

With that you can get the width/height/type much easier. See these
(slightly verbose) examples.
http://textsnippets.com/posts/show/543
http://www.rubyonrailsblog.com/articles/2006/09/08/ruby-on-rails-and-rmagick-crop-resize-rotate-thumbnail-and-upload-images

In particular, you could use something like

file.rewind
img = Magick::Image.from_blob(file.read)[0]

Then width & height are available in img.columns and img.rows

Well, I intend this to make it onto RubyForge one day, but since you have a need :wink: Drop this into your RAILS_ROOT/lib and Enjoy! If you want the test/unit/image_size_test.rb, send me an offline email.

-Rob

# image_size.rb

http://pastie.caboo.se/58251

One of these days I need to put everything like this into an anonymously accessible repository, but this will do for now.

-Rob

Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com

Can you send me an offline email (i.e., not through the mailing list or forum) that has both the JPEG file and the actual code you're using? I suspect that there's just a quirk in your JPEG file (I ran into a few oddities myself) that needs a new unit test to uncover. It looks like the end-of-file is being reached without finding the segment that contains size information.

-Rob

Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
Skype: rob.biedenharn