Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   Im trying to make Thumbnail pics -- any suggestions? (http://www.velocityreviews.com/forums/t846142-im-trying-to-make-thumbnail-pics-any-suggestions.html)

wiz_pendases@yahoo.com 11-28-2007 05:30 PM

Im trying to make Thumbnail pics -- any suggestions?
 
Im trying to make Thumbnail pics -- any suggestions? (dont know wher
to start)

Piyush Ranjan 11-28-2007 05:45 PM

Re: Im trying to make Thumbnail pics -- any suggestions?
 
Note: parts of this message were removed by the gateway to make it a legal Usenet post.

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)
>
>



Eric Tucker 11-28-2007 06:08 PM

Re: Im trying to make Thumbnail pics -- any suggestions?
 
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)
>
>



Aria Stewart 11-28-2007 06:27 PM

Re: Im trying to make Thumbnail pics -- any suggestions?
 

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
>


Or ImageScience or the epeg library


Tom Reilly 11-28-2007 11:01 PM

Re: Im trying to make Thumbnail pics -- any suggestions?
 
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


Ryan Davis 11-29-2007 12:29 AM

Re: Im trying to make Thumbnail pics -- any suggestions?
 

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 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


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



Thufir 11-29-2007 02:30 AM

Re: Im trying to make Thumbnail pics -- any suggestions?
 
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



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



Andrew Stewart 11-29-2007 09:59 AM

Re: Im trying to make Thumbnail pics -- any suggestions?
 

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
>> 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?


Have a look at the attachment_fu plugin:

http://svn.techno-weenie.net/project...attachment_fu/

Regards,
Andy Stewart

-------
http://airbladesoftware.com





John Joyce 11-29-2007 12:00 PM

Re: Im trying to make Thumbnail pics -- any suggestions?
 

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.


Piyush Ranjan 11-30-2007 07:50 AM

Re: Im trying to make Thumbnail pics -- any suggestions?
 
Note: parts of this message were removed by the gateway to make it a legal Usenet post.

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.
>
>




All times are GMT. The time now is 02:57 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.