class Paperclip::Papercrop

Public Instance Methods

crop_command() click to toggle source
# File lib/paperclip_processors/papercrop.rb, line 15
def crop_command
  target = @attachment.instance

  if target.cropping?(@attachment.name)
    begin
      w = Integer(target.send :"#{@attachment.name}_crop_w")
      h = Integer(target.send :"#{@attachment.name}_crop_h")
      x = Integer(target.send :"#{@attachment.name}_crop_x")
      y = Integer(target.send :"#{@attachment.name}_crop_y")
      ["-crop", "#{w}x#{h}+#{x}+#{y}"]
    rescue Exception => e
      ::Papercrop.log("[papercrop] #{@attachment.name} crop w/h/x/y were non-integer. Error: #{e.to_s}")
      return 
    end
  end
end
transformation_command() click to toggle source
Calls superclass method
# File lib/paperclip_processors/papercrop.rb, line 6
def transformation_command
  if crop_command
    crop_command + super.join(' ').sub(/ -crop \S+/, '').split(' ')
  else
    super
  end
end