Class: Paperclip::Cropper

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

Overview

Crop an image

Instance Method Summary (collapse)

Instance Method Details

- (Object) crop_command



19
20
21
22
23
24
# File 'lib/paperclip_processors/cropper.rb', line 19

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

- (Object) transformation_command



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/paperclip_processors/cropper.rb', line 6

def transformation_command
  if crop_command
    original_command = super
    if original_command.include?('-crop')
      original_command.delete_at(super.index('-crop') + 1)
      original_command.delete_at(super.index('-crop'))
    end
    crop_command + original_command
  else
    super
  end
end