Resizing images in rails?

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

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

Become an About.com Guide: beaguide.about.com
About.com is part of the New York Times Company