paperclip error while reporcessing after rails 3 upgrade

后端 未结 2 1737
情书的邮戳
情书的邮戳 2020-12-16 08:17

I have paperclip working uploading and saving different styles for images but when i go to crop the image using jcrop from railscasts tutorial it doesnt crop image. I get

2条回答
  •  执笔经年
    2020-12-16 08:40

    Hereis my working file:

    module Paperclip
      class Cropper < Thumbnail
        def transformation_command
          if crop_command
            crop_command + super.join(' ').sub(/ -crop \S+/, '').split(' ') # super returns     an array like this: ["-resize", "100x", "-crop", "100x100+0+0", "+repage"]
          else
            super
          end
        end
    
        def crop_command
          target = @attachment.instance
          if target.cropping?
            ["-crop", "#{target.crop_w}x#{target.crop_h}+#{target.crop_x}+#{target.crop_y}"]
          end
        end
      end
    end
    

提交回复
热议问题