How to create thumbnail

18 views
Skip to first unread message

debadatta

unread,
Jul 8, 2010, 6:22:18 AM7/8/10
to Ruby on Rails: Talk
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..

catz

unread,
Jul 8, 2010, 8:27:28 AM7/8/10
to rubyonra...@googlegroups.com
Just try paperclip, very simple solution for it.

Ar Chron

unread,
Jul 8, 2010, 8:46:47 AM7/8/10
to rubyonra...@googlegroups.com
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.
--
Posted via http://www.ruby-forum.com/.

debadatta

unread,
Jul 8, 2010, 9:20:07 AM7/8/10
to Ruby on Rails: Talk
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

debadatta

unread,
Jul 9, 2010, 8:23:01 AM7/9/10
to Ruby on Rails: Talk
:style => is not working for paperclip gem in my app
please help


thanks

danny thyui

unread,
Jul 15, 2013, 4:05:56 AM7/15/13
to rubyonra...@googlegroups.com
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.
http://www.rasteredge.com/how-to/csharp-imaging/thumbnail-creating/

Rick

unread,
Jul 15, 2013, 7:03:17 AM7/15/13
to rubyonra...@googlegroups.com
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 https://github.com/thoughtbot/paperclip.

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.
Reply all
Reply to author
Forward
0 new messages