201012 aug

Fleximage rails plugin for images

I looked at a few image plugins for rails.  My requirements:

  • Arbitrary rmagick transformations
  • Automatic fetching of remote images from a url
  • Easy import from local file system
  • Handling of file uploads
  • On-demand of generation of transformed images

Dragonfly looked promising, but I first went with fleximage, because of its simpler support for local and remote file imports.  I didn’t like that it wanted images to have their own models, but since I only needed one image per model, I decided it would work with my existing models.

In the end, fleximage had some fatal flaws:

  • Fleximage generates images on the fly, with no file system caching.  This means that any time you are running without a page cache, you are doing all your transformations on every request.  That is a pain in development, and relying on a transient page cache to preserve the results of a very expensive computation is not acceptable.
  • Fleximage uses it’s own templates with a .flexi extension.  These are mapped to controller actions the same way .haml or .erb files.  Unfortunately, this is a largely useless and cumbersome step.  There is no reason to define a template and a route for a simple transform that can be declared in view, something dragonfly handles much more sensibly.  It also unnecessarily separates file types, so you need to call image_product_path(‘foo’, :png) in order to reach your image.png.flexi “template”.  The creation of a new type of template is just an unnecessary complication.
  • Fleximage only supports one image for each model, and the name of the attribute is hard coded.  This greatly limits the gem’s flexibility and in many cases necessitates unnecessary models.  The principal is that each image is its own resource and deserves its own model.  That may be true in some cases, but not in general and a gem should not enforce this convention.

Fleximage is an interesting attempt to bring RESTful conventions to image processing, but fails to be  practical solution in many cases.

I’ve switched to Paperclip, which I had not realized appears capable of meeting most of my requirements.

There are no responses so far

Leave a Reply