Im trying to make Thumbnail pics -- any suggestions?

Discussion in 'Ruby' started by wiz_pendases@yahoo.com, Nov 28, 2007.

  1. Guest

    Im trying to make Thumbnail pics -- any suggestions? (dont know wher
    to start)
    , Nov 28, 2007
    #1
    1. Advertising

  2. 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, <> wrote:

    > Im trying to make Thumbnail pics -- any suggestions? (dont know wher
    > to start)
    >
    >
    Piyush Ranjan, Nov 28, 2007
    #2
    1. Advertising

  3. Eric Tucker Guest

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

    Date: Thu, 29 Nov 2007 02:45:04
    To: (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, <> wrote:

    > Im trying to make Thumbnail pics -- any suggestions? (dont know wher
    > to start)
    >
    >
    Eric Tucker, Nov 28, 2007
    #3
  4. Aria Stewart Guest

    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
    Aria Stewart, Nov 28, 2007
    #4
  5. Tom Reilly Guest

    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
    Tom Reilly, Nov 28, 2007
    #5
  6. Ryan Davis Guest

    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
    Ryan Davis, Nov 29, 2007
    #6
  7. Thufir Guest

    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
    Thufir, Nov 29, 2007
    #7
  8. 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/projects/plugins/attachment_fu/

    Regards,
    Andy Stewart

    -------
    http://airbladesoftware.com
    Andrew Stewart, Nov 29, 2007
    #8
  9. John Joyce Guest

    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.
    John Joyce, Nov 29, 2007
    #9
  10. 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 <>
    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.
    >
    >
    Piyush Ranjan, Nov 30, 2007
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Lozzi
    Replies:
    1
    Views:
    486
    john smith
    Feb 1, 2006
  2. James Mills
    Replies:
    1
    Views:
    758
    rantingrick
    Aug 3, 2010
  3. Chris Pine
    Replies:
    1
    Views:
    80
    Tim Hunter
    Jul 18, 2004
  4. Trenk
    Replies:
    8
    Views:
    127
    Peter J. Holzer
    Dec 8, 2007
  5. lolo
    Replies:
    3
    Views:
    306
    Charlie
    Jan 15, 2007
Loading...

Share This Page