Agile Web Development

Build it. Launch it. Love it.

Fleximage

There are 2 pieces involved in making Rails image handling easy.

1. Image Uploads

In this post Rails 2, resource driven world, Fleximage believes that images should belong directly to a record. So you simply tell your model have to tell your model class to act as Fleximage, and your model effortlessly gains the ability to handle file uploads.

  • Your model gains the ability to interface directly with a file_field form, allowing uploads with zero extra controller or model code.
  • Accept uploads form a web address, pulling in the image form the internet and saving it locally.
  • Image presence validation with a customizable form field errors message.
  • Image format validation that will not allow the file to be uploaded unless RMagick can parse it into useable image data.
  • Image pre-processing to keep uploaded images under a certain size, or other on-upload image processing tasks.

2. Image Rendering

The other half of the problem comes from the need to send the uploaded images back to the web browser. Most of the time, you need to display the image in different sizes or formats in different places on your site. For example, a product image in a store may need a square thumbnail image, a medium image for its focus page, and a large image for an "enlarge this photo", popup.

Fleximage uses a simple templating engine that allows you to re-render images exactly how you need them. Using the same "master image", many images can be rendered from the same source. You can even go beyond resizing; there is support for image overlays, text drawing, drop shadows, borders and more. The rendering engine is flexible and extensible to whatever your dynamic image needs are.

  • Renderer implemented as template engine, which fits in perfectly with Rails 2 RESTful style format sensitive views.
  • Does not need to have everything resized on upload allowing your site layout the change later on, and all image will re-render themselves just right with your new rendering templates.
  • Support for special effects like text, image or logo overlays, borders, shadows.
  • Extensible by adding image operator classes which allow for reusable snippets of direct RMagick code.
  • Require absolutely zero controller code.

Vitals

Home http://github.com/Squeegy/fleximage/wikis
Repository git://github.com/Squeegy/fleximage.git
License Rails' (MIT)
Tags Tag_red Flex iage image resize rmagick thumbnail upload
Rating (124 votes)
Owner Alex Wayne
Created 22 August 2006

Comments

  • Avatar
    Nils
    2 May 2008

    Why is this under the Model category? It has nothing to do with models. Can someone please remove it from models. It seems only relevant to the Assets category and remotely related to the View Extensions - maybe, but still pushing it.

  • Ferit
    18 September 2008

    I love Fleximage :)

  • Ferit
    19 September 2008

    Best image plugin for rails.

  • Anton
    23 September 2008

    Hello! I am trying to use FlexImage. I’ve got a great problem…

    What do we have: windows, instant rails 2.0, RMagick 2.6.0, Fleximage from url published here.

    I am trying to upload file to database, and, when submit, i see that error: “unable to open image emp/CGI2372-10’: No such file or directory vendor/plugins/fleximage/lib/fleximage/model.rb:224:inread’ vendor/plugins/fleximage/lib/fleximage/model.rb:224:in `image_file=’ ” I debug my programm, at this line inn model.rb we see @uploaded_image = Magick::Image.read(file.path).first file.path is ‘C:/WINDOWS/Temp/CGI2372-10’ I check this folder - file exists. But with next step i am at resque block, and i seee that error. Why is it so strange? Where is the half of the path string? How to make this work?

  • Avatar
    Anton
    26 September 2008

    I noticed a little bug (imho): If i use :image_directory => '...', AND i have got column image_file_data, it saves file in db inspite the fact i defined :image_directory, it's a little confusing

Add a comment