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.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to