Matt W.
2009-Apr-16 22:18 UTC
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.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Shaun Keller
2009-Apr-17 08:19 UTC
Re: Using Paperclip::Processor and RMagick to sharpen my thumbnails
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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Tim Hunter
2009-Apr-17 16:10 UTC
Re: Using Paperclip::Processor and RMagick to sharpen my thumbnails
Matt W. wrote:> image.sharpen(10, 10)!"I''m not having any luck" isn''t a very good description of your problem. However, this is not valid Ruby. It''s possible you meant: image.sharpen!(10,10) but there is no Magick::Image.sharpen! method. I think what you want is: image = image.sharpen(10,10) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Tim Hunter
2009-Apr-17 16:14 UTC
Re: Using Paperclip::Processor and RMagick to sharpen my thumbnails
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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matt W.
2009-Apr-17 19:58 UTC
Re: Using Paperclip::Processor and RMagick to sharpen my thumbnails
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. On Apr 17, 9:10 am, Tim Hunter <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Matt W. wrote: > > image.sharpen(10, 10)! > > "I''m not having any luck" isn''t a very good description of your problem. > However, this is not valid Ruby. It''s possible you meant: > > image.sharpen!(10,10) > > but there is no Magick::Image.sharpen! method. I think what you want is: > > image = image.sharpen(10,10) > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matt W.
2009-Apr-17 20:23 UTC
Re: Using Paperclip::Processor and RMagick to sharpen my thumbnails
How would I go about utilizing the "support" argument with Paperclip? On Apr 17, 9:14 am, Tim Hunter <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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. Seehttp://www.imagemagick.org/RMagick/doc/image3.html#resize. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matt W.
2009-Apr-20 23:54 UTC
Re: Using Paperclip::Processor and RMagick to sharpen my thumbnails
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@ On Apr 17, 1:19 am, Shaun Keller <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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 subclassingPaperclip::Thumbnail instead? > > If not, could you provide more details on the nature of the actual > error? > -- > Posted viahttp://www.ruby-forum.com/.