FAIL: Rails + Images
Posted by BM5k on January 21, 2008 at 02:28 AM
My latest rails project involves uploading images, and having them automagically thumbnailed. So far, it isn’t looking so good.
Upload
Google pointed me at the attachment_fu plugin and a how-to by Mike Clark. Attachment Fu was a pretty simple install/config. Now I can upload images.
This is where the fun ends.
Resizability
The first thing I tried was just sudo gem install mini-magick, which didn’t work because I didn’t have image magick installed. Just to make things easy, Rails doesn’t give an error for this, it simply doesn’t work. Thanks to my development log, I was able to figure it out that this was caused by Error 32512.
However, Google didn’t offer me much in the way of figuring out just what Error 32512 meant. Eventually, I figured out that I’d glanced over the entire install a library to do the resizing part of the tutorial. +10 stupid points
An easy to install, OS X 10.5 image magick doesn’t exist. Period. I even dicked around with MacPorts (not a big fan) and trying to get Image Magick working. No luck, just the same error message.
About 10 minutes after I’d decided to give up (I’m that stubborn/determined to find an easier solution/desperate) I came across a method of using core image to do the dirty work. Seemed easy enough. I don’t use git so I had to use this (from the comments on the main page) download link to get the .gz file. I got everything put in place in my existing attachment_fu setup, restarted mongrel. Now, instead of no resizing, I can’t get the full-size image.
For example, given the following code, I get 2 images, each shrunk to 100×100.
has_attachment :content_type => :image,
:storage => :file_system,
:resize_to => "640x480",
:size => 1.kilobyte .. 3.megabytes,
:thumbnails => { :thumb => "100x100" }However, with this code, I get 1 image at 640×480.
has_attachment :content_type => :image,
:storage => :file_system,
:resize_to => "640x480",
:size => 1.kilobyte .. 3.megabytesFail
As far as resizing goes, this is a complete failure. Dealing with large, original size images was NOT my intention, nor dealing with 2 equally diminutive images.
So, I’ve given up giving up and am gunna pretend like I never wanted fullsize images with thumbnails, and just be glad I can upload images at all. Then I’m going to remove all image-resizing from the code, and pretend like the 6 or so hours I’ve wasted total on this never happened.
Documentation
The things that frustrated me most about this experience is the lack of good information regarding this plugin. Mike Clark seems to be the go-to guy. Googling for attachment_fu, his site is the first hit; googling for problems gives several forum posts that link to his blog. To be honest, I couldn’t find anything wrong with his how to, but it didn’t work for me, and doesn’t cover everything the plugin is capable of.
For some reason, not being able to easily find detailed info (and by detailed I am not referring to the API-DOC) for a plugin on the developer’s site is a big turn off. Compare the google search results for Acts_As_Authenticated to Attachment_Fu weenie Attachment_Fu In both cases the first result is the technoweenie SVN repository. For AAA the next result is the wiki for usage info.
Comments
There is 1 comment on this post. Post yours →
Oops. So there was. It’s tiny though.
Post a comment
Required fields in bold.