Im trying to make Thumbnail pics -- any suggestions? (dont know wher
to start)
Use rmagick which is a sort of a ruby binding on ImageMagick and
grpahicsmagick
···
On Nov 28, 2007 11:05 PM, <wiz_pendases@yahoo.com> wrote:
Im trying to make Thumbnail pics -- any suggestions? (dont know wher
to start)
wiz_pendases@yahoo.com wrote:
Im 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
I am using rmagick. However, I hear good things about imagescience if your needs featurewise are more modest.
Sent wirelessly via BlackBerry from T-Mobile.
···
-----Original Message-----
From: "Piyush Ranjan" <piyush.pr@gmail.com>
Date: Thu, 29 Nov 2007 02:45:04
To:ruby-talk@ruby-lang.org (ruby-talk ML)
Subject: Re: Im trying to make Thumbnail pics -- any suggestions?
Use rmagick which is a sort of a ruby binding on ImageMagick and
grpahicsmagick
On Nov 28, 2007 11:05 PM, <wiz_pendases@yahoo.com> wrote:
Im trying to make Thumbnail pics -- any suggestions? (dont know wher
to start)
Or ImageScience or the epeg library
···
On Nov 28, 2007, at 10:45 AM, Piyush Ranjan wrote:
Use rmagick which is a sort of a ruby binding on ImageMagick and
grpahicsmagick
Blech!
This is exactly why I wrote image_science... well, that and installing ImageMagick/rmagick was always a PITA.
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
···
On Nov 28, 2007, at 15:01 , Tom Reilly wrote:
# Make Thumb Nails
# This works fine to make thumbnails for my web site
# lots of luck
#Tom Reillyrequire 'rmagick'
include Magickdef 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
endtnDir = ".\\"
jpgArray = Array.new
dir = Dir.new(tnDir)
dir.each do |d|
jpgArray.push(d) if d =~ /jpg/
endpix = 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
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
···
On Thu, 29 Nov 2007 09:29:25 +0900, Ryan Davis wrote:
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
Have a look at the attachment_fu plugin:
http://svn.techno-weenie.net/projects/plugins/attachment_fu/
Regards,
Andy Stewart
···
On 29 Nov 2007, at 02:30, Thufir wrote:
On Thu, 29 Nov 2007 09:29:25 +0900, Ryan Davis wrote:
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
endVery 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?
-------
Put things like that into the Model file.
···
On Nov 28, 2007, at 8:30 PM, Thufir wrote:
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
you can also use filecolumn for rails file upload and thumbnailing needs.
···
On Nov 29, 2007 5:30 PM, John Joyce <dangerwillrobinsondanger@gmail.com> wrote:
On Nov 28, 2007, at 8:30 PM, Thufir wrote:
>
> 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
>
>Put things like that into the Model file.