views:

53

answers:

2

Can anyone tell me the way to zoom the image in Ruby on rails please ?

A: 

You should be clearer.

If what you want to do is allow the user to zoom on an image then you should take a look at javascript.
For example jqzoom, which does a zoom on an image when your mouse is on it.

If what you want is to resize the image to a specific size then it's a ruby/rails problem.
And you can use paperclip to do so.

In your model, you'd add the following :

has_attached_file :my_image, :styles => { :thumb => ["32x32#", :png] }

Where the "32x32" will be the size of the image after it's been resized.

Then you follow the paperclip's README to see the migration and informations to add to the view.
And when you'll validate your form, the image will be automatically uploaded and resized.

If you don't wish to upload the files before to resize them, you can use Paperclip::Thumbnail directly.

And resize your image with the following :

Paperclip::Thumbnail.new('/path/to/your/file', { :geometry => '32x32#' }).make

And you'll have your thumbnail.

Damien MATHIEU
Damien Sir, Thank you for ur helpful answer, I have worked on paperclip plugin but what i want is similer to the picasa galary ,, they have a nice option to zoom all the pictures of gallary .. I hope i am clear ! I have that only Example .. If any one can help me do this
Arpit.k.Vaishnav
Then you're looking for JQZoom. Look at the beginning of my post.
Damien MATHIEU
ya i have seen that jqzoom which zoom the image ,,Please look at the gallary of Picasa where there is a trigger given for all the images of galary,, by the way jqzoom is also a nice way for zooming images , thanks for the nice java script .. searching for more ,,
Arpit.k.Vaishnav
A: 

There's railscast #182 on image Cropping.

If you are using Paperclip, you may specify different sizes for thumbnails, like this:

class Client < ActiveRecord::Base

  LOGO_STYLES = {
    :original => ['1024x768>', :jpg],
    :big      => ['512x384#', :jpg],
    :medium   => ['256x192#', :jpg],
    :small    => ['128x96#', :jpg]
  }

  has_attached_file :logo, :styles => Client::LOGO_STYLES
  attr_protected :logo_file_name, :logo_content_type, :logo_size

Finally, if you already have the image with the size you want, and you only want to change how it looks on the client, then your problem isn't ruby - it is javascript. Google for "javascript zoom" instead of "rails zoom" :)

egarcia