rcoder@gmail.com
12/20/2004 8:48:00 PM
Phil,
I'm working on some RMagick-based web gallery code right now, as I know
several people (myself included) who want to set up 'photo-a-day'
blogs. Unfortunately, with all the holiday craziness, I haven't had
time to do much more than tinker with it, but the basic code to do
resizing is pretty straightforward.
Here's a snippet from the work-in-progress:
---
require 'RMagick'
THUMB_MAX_X = 120
THUMB_MAX_Y = 90
images = Dir['images/*']
images.each do |imgfile|
image = Magick::Image.read(imgfile).first
xscale = THUMB_MAX_X.to_f / image.columns
yscale = THUMB_MAX_Y.to_f / image.rows
factor = (xscale < yscale) ? xscale : yscale
thumb = image.scale(factor)
outfile = 'thumbs/'+File.basename(imgfile)
thumb.write(outfile)
end
---
There's really not much to it aside from that, aside from uploads
(Net::SFTP), templating (ERb), and metadata (EXIF+YAML+???).
Lennon