StringIO to Tempfile?

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

With that you can get the width/height/type much easier. See these
(slightly verbose) examples.

In particular, you could use something like

img = Magick::Image.from_blob([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.


# image_size.rb

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


Rob Biedenharn

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 Biedenharn
Skype: rob.biedenharn