resizing images in rails?

Discussion in 'Ruby' started by Ravi Katta, Aug 27, 2008.

  1. Ravi Katta

    Ravi Katta Guest

    Hi,

    how to resize the images in rails app?
    i want 400X300 size images to display in my app.But if user enter
    600X800 how to resize the image without effect on clarity?

    now i am using this code

    image =
    Magick::Image.read("#{RAILS_ROOT}/public/gallery/#{review_img}").first
    selected_image = image.crop_resized(400,400)
    selected_image.write("#{RAILS_ROOT}/public/gallery/#{review_img}")

    But it extract height and width.i dont want to extract only resize
    the image.
    any suggestion are appreciated.

    thanks,
    ravi.
    --
    Posted via http://www.ruby-forum.com/.
    Ravi Katta, Aug 27, 2008
    #1
    1. Advertising

  2. Ravi Katta

    Tim Hunter Guest

    Ravi Katta wrote:
    >
    >
    > Hi,
    >
    > how to resize the images in rails app?
    > i want 400X300 size images to display in my app.But if user enter
    > 600X800 how to resize the image without effect on clarity?
    >
    > now i am using this code
    >
    > image =
    > Magick::Image.read("#{RAILS_ROOT}/public/gallery/#{review_img}").first
    > selected_image = image.crop_resized(400,400)
    > selected_image.write("#{RAILS_ROOT}/public/gallery/#{review_img}")
    >
    > But it extract height and width.i dont want to extract only resize
    > the image.
    > any suggestion are appreciated.
    >
    > thanks,
    > ravi.


    Here's a description of RMagick's resizing methods:
    http://studio.imagemagick.org/RMagick/doc/comtasks.html#thumb. Also see
    the section "Resizing to a maximum (or minimum) size".
    --
    Posted via http://www.ruby-forum.com/.
    Tim Hunter, Aug 27, 2008
    #2
    1. Advertising

  3. Ravi Katta wrote:
    >
    > Hi,
    >
    > how to resize the images in rails app?
    > i want 400X300 size images to display in my app.But if user enter
    > 600X800 how to resize the image without effect on clarity?
    >
    > now i am using this code
    >
    > image =
    > Magick::Image.read("#{RAILS_ROOT}/public/gallery/#{review_img}").first
    > selected_image = image.crop_resized(400,400)
    > selected_image.write("#{RAILS_ROOT}/public/gallery/#{review_img}")
    >
    > But it extract height and width.i dont want to extract only resize
    > the image.
    > any suggestion are appreciated.
    >
    > thanks,
    > ravi.


    First, resizing 400x300 to 600x800 changes the aspect ratio. The image
    will appear "squashed." Second, scaling up will always involve some
    pixelization, blurriness or other unwanted things. Third, you can have
    the web browser do this for you. See the width and height attributes to
    the img tag.

    --
    Michael Morin
    Guide to Ruby
    http://ruby.about.com/
    Become an About.com Guide: beaguide.about.com
    About.com is part of the New York Times Company
    Michael Morin, Aug 28, 2008
    #3
    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. Ron Vecchi
    Replies:
    1
    Views:
    382
  2. Clyde Ellul

    Resizing GIF images: please help!

    Clyde Ellul, Oct 16, 2003, in forum: Java
    Replies:
    6
    Views:
    544
    Millian Brave
    Oct 16, 2003
  3. BG Mahesh
    Replies:
    1
    Views:
    411
    Roedy Green
    Jan 13, 2006
  4. Pil (Trustworthy from Experience)

    Resizing a div by resizing its borders

    Pil (Trustworthy from Experience), Apr 18, 2009, in forum: Javascript
    Replies:
    9
    Views:
    336
    Proper
    Apr 21, 2009
  5. Proper
    Replies:
    0
    Views:
    189
    Proper
    Apr 18, 2009
Loading...

Share This Page