Class: Paperclip::PaperCropper

Inherits:
Thumbnail
  • Object
show all
Defined in:
lib/paperclip_processors/paper_cropper.rb

Instance Method Summary collapse

Instance Method Details

#crop_commandObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/paperclip_processors/paper_cropper.rb', line 13

def crop_command
  target = @attachment.instance

  if target.cropping?(@attachment.name)
    begin
      x = Integer(target.send :"#{@attachment.name}_crop_x")
      y = Integer(target.send :"#{@attachment.name}_crop_y")
      w = Integer(target.send :"#{@attachment.name}_crop_width")
      h = Integer(target.send :"#{@attachment.name}_crop_height")
      ["-crop", "#{w}x#{h}+#{x}+#{y}"]
    rescue Exception => e
      ::PaperCropper.log("[paper_cropper] #{@attachment.name} crop w/h/x/y were non-integer. Error: #{e.to_s}")
      return
    end
  end
end

#transformation_commandObject



5
6
7
8
9
10
11
# File 'lib/paperclip_processors/paper_cropper.rb', line 5

def transformation_command
  if crop_command
    crop_command + super.join(' ').sub(/ -crop \S+/, '').split(' ')
  else
    super
  end
end