Fleximage v2, now with more awesome
April 5th, 2008
You ever make something, and then look back a few years later and say “What the hell was I thinking”? This happened to me recently. Fleximage has been quite a useful plugin for me, but under the hood it was a mess; the API was cumbersome, and mixing in all the image transformations as direct model methods was code smell.
This release represents the 3rd complete rewrite of this code base. The first effort was SuperImage. It worked, but it happened almost entirely in the controller and made more interesting effects harder. The first Fleximage was next introducing more tranformations and .flexi views and a good effort to making it more MVC friendly.
Get Fleximage v2 here
So I now present, Fleximage v2. The output is very similar, but the API and internals are completely different. Here’s some highlights.
- Creation date based master image storage to prevent OS imposed directory limits. i.e. /path/to/images/2008/02/06/999.jpg
- Rails 2 formatted resource route friendly
- Magic columns to capture filename and image size
- Image transformation methods are not injected into your model or controller at all.
- Image operations now happen via Operator class that refactor each transformation into their own encapsulated class.
- Easily output JPG, PNG, or GIF based on request format.
- Simple acts_as_* style model activation rather than using a cumbersome inheritance method
- Side by side file upload or URL fields for easy uploading.
- Uploading will only ever replace you image file if the uploaded file actually has content, removing the need for “if file.size > 0” nonsense in your controller.
- Rake tasks to convert from master image directory styles, as well as master image formats (jpg => png for instance)
And it’s all hosted on GitHib. It’s new, it’s awesome, and has extensive documentation in the attached Wiki.
Lastly, if you are using Fleximage in an existing production site, please add it on the WhoUsesFleximage page. I know you’re out there.
April 5th, 2008 at 06:19 PM
So, you decided to totally dump the DB stored images? Or, hopefully, the support will be added later? Any particular reason why it was removed?
I use FlexImage on over 30+ sites I have built (sorry, , and all of them used DB storage for images, because this way I have easier workflow (I can move just DB from our development machine, where all the site information is actually entered before going public, and don’t worry about any images I have forgot). Also, I believe this approach is also less prone to data corruption.
Not having DB storage supported is, honestly, a pretty big blow for me.. Hopefully it will be re-added.
Anyways, congratulations on the release and keep up the good work!
April 5th, 2008 at 09:27 PM
Perhaps as a sister plugin, but for most people it’s probably not the right choice.
I have mixed feelings about it. And DB support is one thing that made the last version’s code so messy. I’m sure there is a solution here, but it hasn’t been tackled yet.
Accepting patches :) Or if you have a github account, you can just fork me and work on your own version of the repo. Need an invite?
April 5th, 2008 at 09:31 PM
By the way, I would love to know some of the sites you have that use Fleximage. Care to post them?
April 5th, 2008 at 09:36 PM
What columns are needed on DB? Can you post an example migrate at wiki?
April 5th, 2008 at 11:12 PM
I had an idea about this that was surprisingly easy to implement. Just include a
image_file_databinary field and the plugin will automatically shove image data in there. More info here:http://github.com/Squeegy/fleximage/wikis/databaseorfilesystemstorage
I just didn’t really want to be supporting the issues that come with this, like getting people to constrain their common SQL from querying binary columns and other headaches. So I added the support, with the clause that I recommend file system based approaches.
@Lucas: If you are using file system storage, no database columns are needed at all. Currently there is no rake tasks to migrate between DB and filesystem stores, but I think I can make that happen. Stay tuned.
April 6th, 2008 at 07:59 AM
Hi, nice to hear about an update. I’am using DB-storage too. For my next project I’ll try the new version (with DB-storage). Very nice plugin, thanks a lot!
April 6th, 2008 at 10:35 PM
Thanks for the update!
As for sites I use FlexImI mostly use FlexImage for simple image manipulation and image storage, so they definitely don’t look anything close to the featured WineSpies :)
But anyways, here’s the list of some sites :) Everything except for the first one are in Japanese (working at a Japan-based company currently, so.. oh well.. :)
http://rightviewpro.com/ http://gakuenblog.com/ http://www.kyosyoen.com/ http://www.sudo-saketen.com/ http://www.maidsalon-hermes.com/ http://www.sakelife-tomu.com/ http://www.kimonokurachi.com/ http://www.kyo-roman.com/ http://www.sake-no-tamagoya.com/
Nothing visually spectacular though. Feel free to include or not include these to your list :)
April 11th, 2008 at 11:42 AM
Thanks Mike! Your comment got spam filtered, sorry for the delay.
I have added them to the list Who uses Fleximage list.
April 12th, 2008 at 12:12 PM
I couldnt find where to submit bugs, but its a pretty simple bug. I am using the flex image edge. When you do:
some_obj.image_file = File.open(“path_to_jpg”)
A file object does not have a method “original_filename”. So when trying to set the magic attributes you get an undefined method error. It’s on line 377.
Thought this would help.
April 12th, 2008 at 01:52 PM
Thanks Ben, nice find. Rails (and the CGI library) has like 3 classes it uses to upload files, and then there is there is an instance of
File. It’s all a bit cumbersome to support all the APIs.I just committed a fix here
It will ask for
original_filenameorbasenamewhich should work withFileinstances.April 19th, 2008 at 06:02 PM
Hey Alex,
Thanks for the plugin – it looks great.
I am currently using AttachmentFu for its S3 capabilities, which I need for my current project. Is there an established way to store to S3 using Fleximage? If not, I would be happy to work on it and contribute back to the community. In this case, I was wondering if you could give me a few initial pointers to get started faster.
Thanks, OA
April 20th, 2008 at 12:46 PM
I have not used S3 just yet, so I am unfamiliar with the API. Although I am sure support would not be hard to add.
Here some methods you will want to look at from Fleximage::Model
Monkeying with those methods should be all you need to make Fleximage work with S3.
Probably about time I hopped on that bandwagon, eh?
May 25th, 2008 at 05:44 PM
Hi Alex,
Thanks for the plugin. I’m guessing Fleximage V2 will not work on rails 1.2.3 because Mime::Type.register_alias in the init.rb file only works in Rails 2.0.
If I comment off that line, would the plugin still work as normal?
Thanks!
June 17th, 2008 at 08:05 PM
I love the plugin! I would second the appreciation of S3 support.