How to create thumbnail

Hi all   I want to create thumbnail for a uploaded image file, I have a product controller and model with a image field .I want file uploaded in the image field should have one thumbnail file and also one general. I have tried a lot by installing plugins for thumbnails but they are not working rendering errors like PLUGIN not found..

Please , give me some suggestions where I will create which controller and action to create a thumbnail....

Thanks in advance..

Just try paperclip, very simple solution for it.

catz wrote:

Just try paperclip, very simple solution for it.

+1 for the paperclip recommendation, but you also need some image processing package installed and available... ImageMagick, or something similar.

Then it's almost as simple as:

class Image < ActiveRecord::Base   has_attachment :content_type => ['image/jpeg', 'image/png'],                  :storage => :file_system,                  :max_size => 500.kilobytes,                  :resize_to => '800x600>',                  :thumbnails => { :thumb => '100x100>'} end

in your model. There are plenty of tutorials out there available via Googling.

Hi Catz and Ar chron thanks for giving idea for using paperclip ..But it's not installing from their repository sites .Can I download the repository and copy it into my vendor/plugins dir ....? and should it work???

thanks

:style => is not working for paperclip gem in my app please help

thanks

I do this almost daily. I use an imaging sdk which can create thumbnails found on the internet . Install it and it becomes a selectable processing option.Then you can create thumbnails in your image in any program at all, including Adobe Acrobat . Just open the images, select thumbnail,and follow the setps given in the sdk, the task will be finished in several seconds. if you haven't found a good choice , you can have a try. best wishes.

It’s really hard to help you without seeing the code that is causing the error and the log that gives the details of the error message. For example, your problem could be as simple as using :style => (singular) instead of :styles => (plural) in your model.

Also, it’s could be that you are using a version of ruby and/or rails that is not supported with the version of paperclip you have installed. But, as above, it’s impossible to tell without more information.

That said, I often find the best way to build confidence in a new gem is to follow the examples given in the documentation that comes with the gem. Build yourself a new app that will only be used to upload and display images. Then follow through the examples given in the README.md at GitHub - thoughtbot/paperclip: Easy file attachment management for ActiveRecord.

The paperclip gem and ImageMagick are tools that get a lot of use in RoR code. They will work for you if you follow the directions for use.