W
wiz_pendases
Im trying to make Thumbnail pics -- any suggestions? (dont know wher
to start)
to start)
Use rmagick which is a sort of a ruby binding on ImageMagick and
grpahicsmagick
# Make Thumb NailsIm trying to make Thumbnail pics -- any suggestions? (dont know wher
to start)
# Make Thumb Nails
# This works fine to make thumbnails for my web site
# lots of luck
#Tom Reilly
require 'rmagick'
include Magick
def rsz(hgt,wdt,msze)
if hgt > wdt
r = msze.to_f / hgt.to_f
return [ msze, (wdt.to_f * r).to_i]
else
r = msze.to_f / wdt.to_f
return [(hgt.to_f * r).to_i, msze]
end
end
tnDir = ".\\"
jpgArray = Array.new
dir = Dir.new(tnDir)
dir.each do |d|
jpgArray.push(d) if d =~ /jpg/
end
pix = ImageList.new
jpgArray.each {|x| pix.read(x) if x .downcase =~ /jpg/}
pix.each do |x|
rows = x.rows
columns = x.columns
factor1 = 200
factor2 = 450
a = rsz(columns,rows,factor1)
x.resize!(a[0],a[1])
#img.resize!(cols,rows)
# img2 = x.frame
x.write(".\\stamp\\#{"t" + x.filename}")
end
require 'rubygems'
require 'image_science'
Dir["*.jpg"].each do |file|
ImageScience.with_image(file) do |img|
img.thumbnail(200) do |thumb|
thumb.save "#{file.sub(/.jpg$/, '')}_thumb.png"
end
end
end
require 'rubygems'
require 'image_science'
Dir["*.jpg"].each do |file|
ImageScience.with_image(file) do |img|
img.thumbnail(200) do |thumb|
thumb.save "#{file.sub(/.jpg$/, '')}_thumb.png"
end
end
end
Very cool
I'm ok with the ruby, but how would you put that *into* a rails
project
so that the above code is run when the new images are imported to
the db?
Very cool
I'm ok with the ruby, but how would you put that *into* a rails
project
so that the above code is run when the new images are imported to
the db?
thanks,
Thufir
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.