- Install MacPorts by following the instructions. A .profile should be created by the install script. It didn't feel like doing that on my system, so I created a .profile file in my home directory with this contents:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH export MANPATH=/opt/local/share/man:$MANPATH
- Restart Terminal.app
- Update the MacPorts ports:
sudo port selfupdate
- Install FreeImage:
sudo port install freeimage
- Install RubyInline:
sudo gem install RubyInline
- Install the ImageScience gem:
sudo gem install -y image_science
- Finally install the attachment_fu plugin (run this in your Rails project directory):
script/plugin install http://svn.techno-weenie.net/projects/plugins/attachment_fu/
Q&A
Q: Why did you use attachment_fu and not one of the other file upload plugins? A: Because (1) Rick Olsen knows what he is doing, (2) is a Rails core contributor and (3) has a proven record of great plugins. Oh, and because attachment_fu seems to (4) be actively maintained and (5) supports file system, database and even Amazon S3 data stores. Q: Why did you choose FreeImage and ImageScience and not ImageMagick and RMagick or MiniMagick? A: Especially RMagick has the reputation of being a leaking memory hog. I haven't tried it myself, but ImageScience and FreeImage seem to be a lean choice and they do a great job. If this was useful for you, please take a minute and recommend me:Thank you!
Comments
Johannes Fahrenkrug said...
Hi Richard,
Thanks for your comment. I don't know enough about your environment to pinpoint what your problem might be, so I'll just tell you something you can try to make sure your filters really work:
Add "rezize_to" to your has_attachment call, so it looks something like this:
has_attachment :content_type => :image, :size => 1..5.megabytes, :resize_to => 'x300'
Now upload some big images and check if they get resized. If not, your filter doesn't work. Also note that of course thumbnails are only created for image uploads. Check attachment_fu's README for more details.
The *_url methods are part of the named routes in Rails:
http://wiki.rubyonrails.org/rails/pages/NamedRoutes
Please let me know how it works out!
- Johannes
SnowmanInTheSun said...
I can't seem to get the thumbnail feature working. All my image processors are installed correctly, and i've spent a few hours researching but to no avail. I can save and retrieve files perfectly fine, but for whatever reason a photo_thumb.jpg is never created. Do you have any guesses??
Also i'm unfamiliar with "redirect_to @something_url(@something)' i just used :action => 'show'. Let me know if this would make a difference, and maybe give me a link explaining how this works.
OSX - Leopard
Rails - 2.0.2
Morten K. Holst said...
Johannes, a HUGE thanks from here.. Everything is working like a charm now!
June 30, 2008 08:15 PMThis is the kind of stuff RoR-beginners need to get going.