ImageScience is a clean and happy Ruby library that generates thumbnails -- and kicks the living crap out of RMagick. Oh, and it doesn't leak memory like a sieve. :)
ImageScience.with_image(file) do |img|
img.cropped_thumbnail(100) do |thumb|
thumb.save "#{file}_cropped.png"
end
img.thumbnail(100) do |thumb|
thumb.save "#{file}_thumb.png"
end
img.resize(100, 150) do |img2|
img2.save "#{file}_resize.png"
end
end
sudo gem install -y image_science
Unfortunately there are minor issues with the makefiles in FreeImage. Until I get commit bits or get the issues resolved, I will try to keep detailed notes here. I'll keep updating them over time.
cvs -z3 -d:pserver:anonymous@freeimage.cvs.sourceforge.net:/cvsroot/freeimage login
# hit return at password prompt
cvs -z3 -d:pserver:anonymous@freeimage.cvs.sourceforge.net:/cvsroot/freeimage co -D 2007-01-01 -P FreeImage
cd FreeImage
sudo port selfupdate
sudo port install freeimage
NOTE: OSX builds a fat binary, so you need to have the 10.3.9 and 10.4 SDK's installed, preferably from xcode 2.3. They are in the "cross-compiling" section of the xcode install options.
NOTE: OSX needs to be using gcc 4.x:
gcc_select 4.0
This mostly affects PPC / 10.4 users.
Use 2007-02-11
instead of the date above on the cvs co
. Especially if you see:
/usr/bin/ld: ./Source/FreeImage/BitmapAccess.o: relocation R_X86_64_32S against
`a local symbol' can not be used when making a shared object;
recompile with -fPIC
or:
Source/Metadata/Exif.cpp:498: error: cast from 'BYTE*' to 'DWORD' loses precision make[1]: *** [Source/Metadata/Exif.o] Error 1Special Thanks to Matt Mower and Carmelyne.
aptitude install libfreeimage3 libfreeimage3-dev
If you see:
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
Then ubuntu/debian decided it was a good idea not to symlink the versioned libc++.so to the unversioned one... you know, the one everyone actually links to. You can usually fix it via:
% sudo ln -s libc++.so.* libc++.so
in the appropriate directory.
make
PATH=$PATH:/usr/sbin sudo make install
Also, court3nay points out that the default SELinux setup will complain at runtime when image_science tries to load FreeImage. Try this suggestion to enable it.
Hugh notes that he had to change Source/FreeImage.h
from #include <stdint.h>
to #include <inttypes.h>
.
make
sudo make install
If that doesn't work, please file a bug and I'll try to help you figure it out and get some notes up here.