Using Paperclip::Processor and RMagick to sharpen my thumbnails

Hi, I'm brand new to RMagick (and pretty new to Rails for that matter!). Right now, site owners are allowed to upload product and ingredient photos to the website. Everything works great, ingredients are sized down and proportioned correctly...the problem is that the resulting images are so blurry! So I've been doing some research and it looks like Paperclip::Processor may be the way to go. Here is what I have so far:

*** RAILS_ROOT/lib/paperclip_processors/paperclip_sharpen_image.rb ***

require 'RMagick'

module Paperclip     class SharpenImage < Paperclip::Processor

        def initialize file, options = {}             super             @file = file             @format = options[:format]             @current_format = File.extname(@file.path)             @basename = File.basename(@file.path, @current_format)         end

        def make             src = @file             image = Magick::Image.read(File.expand_path (src.path)).first

            image.sharpen(10, 10)!

            # Create Templfile object and write image data to its file             dst = Tempfile.new([@basename, @format].compact.join("."))             dst.binmode             image.write(File.expand_path(dst.path))

            # Return Tempfile object to Paperclip for further handling             return dst         end     end end

*** ingredient.rb ***

has_attached_file :photo, :styles => {:small => "63x75"},                             :processors => [:sharpen_image]

But, I'm not having any luck. I just grabbed most of this code from another site and have been trying to adapt it...but to no avail! Any help or advice would be greatly appreciated!

Thanks.

Depends what exactly your error is, but I seem to recall RMagick having issues with TempFile's default naming convention. The default processor deals with that. Try subclassing Paperclip::Thumbnail instead?

If not, could you provide more details on the nature of the actual error?

Matt W. wrote:

Hi, I'm xxxxx new to RMagick (and pretty new to Rails for that matter!). Right now, site owners are allowed to upload product and ingredient photos to the website. Everything works great, ingredients are sized down and proportioned correctly...the problem is that the resulting images are so blurry!

Magick::Image.resize takes a "support" (a.k.a "sharpen") argument. See http://www.imagemagick.org/RMagick/doc/image3.html#resize.

I apologize for the poor description. What I should have said is that nothing appears to happen at all. I don't see any errors logged, the thumbnail is still created, but it doesn't appear to be any different than before (when I wasn't using the processor). I appreciate everyone's feedback, looks like I've got a couple of things I can try.

Thanks.

How would I go about utilizing the "support" argument with Paperclip?

It seems that my processor isn't even being fired. There is no evidence that it is even being called. I have it in the RAILS_ROOT/lib/ paperclip_processors directory and I've double checked the file names. Does anyone have any idea what I'm doing wrong here?

Thanks!

M@