小编bal*_*ala的帖子

回形针锐化处理器导致调整样式不起作用

我正在尝试锐化通过回形针上传的图像.锐化代码正在工作,但它导致样式不起作用.代码是这样的:

 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"
Run Code Online (Sandbox Code Playgroud)

现在,如果我删除处理器选项,则按指定调整上传的图像大小.但是,如果我包含处理器选项,则所有生成的图像都是原始大小.

我的锐化处理器看起来像这样:

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) …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails paperclip

1
推荐指数
1
解决办法
1208
查看次数

标签 统计

paperclip ×1

ruby-on-rails ×1