Paperclip sharpening processor causes resizing styles not to work
I'm trying to sharpen images uploaded through paperclip. The sharpen code is working but it causes the styles to not work. The code is like this:
has_attached_file :photo,
:styles => {
:thumb => {:geometry => "100x100>"},
:medium => {:geometry => "300x300>"},
:original => {:geometry => "1024x1024>"}
},
:processors => [:sharpen],
:storage => :s3,
:s3_credentials => "#{Rails.root}/config/s3.yml",
:path => "/:style/:id/:filename"
Now if I remove the processors option, the uploaded images are resized as specified. However if I include the processors option, all the resulting images are of original size.
My sharpen processor looks like this:
module Paperclip
class Sharpen < Paperclip::Processor
def initialize file, options = {}, attachment = nil
super
@file = file
@current_format = File.extname(@file.path)
@basename = File.basename(@file.path, @current_format)
end
def make
dst = Tempfile.new(@basename)
dst.binmode
command = "#{File.expand_path(@file.path)} -unsharp 1.5×1.0+1.5+0.02 #{File.expand_path(dst.path)}"
begin
success = Paperclip.run("convert", command)
rescue PaperclipCommandLineError
raise PaperclipErr开发者_如何学运维or, "There was an error converting sharpening the image for #{@basename}"
end
dst
end
end
end
Any thoughts?
Try adding :thumbnail
to processors list:
:processors => [:thumbnail, :sharpen]
By default :thumbnail
is there but now you are overriding that setting.
"Multiple processors can be specified, and they will be invoked in the order they are defined in the :processors array. Each successive processor will be given the result of the previous processor's execution. All processors will receive the same parameters, which are what you define in the :styles hash."
- https://github.com/thoughtbot/paperclip
精彩评论