resizing images in rails?

R

Ravi Katta

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

Tim Hunter

Ravi said:
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".
 
M

Michael Morin

Ravi said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top