1. Skip to navigation
  2. Skip to content

The ELC Community Blog

A knowledge exchange on Ruby on Rails and Agile Development


ImageVoodoo File Extensions

by Dylan Stamat on May 30, 2008

Sparing the details, a project of ours uses a custom built content processor, and not AttachmentFu. It works wonderfully, but I ran into some caveats in regard to how ImageVoodoo handles images. After some digging, I found an interesting post by Nick, which actually touches on my problem indirectly.

In an nutshell, ImageScience allows the loading of extension-less images, which ImageVoodoo does not, ie:

   1  >> ImageScience.with_image("/Users/dstamat/5a1e81c76e634dfc5005db0b1fdf5c58_CGI.11279.6") {}
   2  => nil
   3  >> ImageVoodoo.with_image("/Users/dstamat/5a1e81c76e634dfc5005db0b1fdf5c58_CGI.11279.6") {} 
   4  TypeError: unrecognized format for /Users/dstamat/5a1e81c76e634dfc5005db0b1fdf5c58_CGI.11279.6
   5  	from /Users/dstamat/src/work/.../vendor/gems/image_voodoo-0.2/lib/image_voodoo.rb:180:in `with_image'
   6  	from (irb):8:in `signal_status'

The "solution" in terms of getting this to work properly is to override Tempfile#make_tmpname to allow the slipping in of the file extension, as seen in Nick's post.

To make the libraries consistent however, that's TBD. Each library obviously uses different means for introspection. ImageScience uses FreeImage_GetFIFFromFilename and FreeImage_FIFSupportsReading to determine compatibility, while ImageVoodoo uses Java's ImageIO.getImageReadersBySuffix and writes with ImageIO.write, which requires a format (and will consequently write out the file but not stream).

Will hack up a patch if time permits... but, this will hopefully shed some light for those running into this problem as well :)

Comments

Add a comment


home | services | Ruby on Rails Development | code | blog | company