Class: Paperclip::Jcropper

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

Instance Method Summary collapse

Instance Method Details

#crop_stringObject



20
21
22
# File 'lib/paperclip_processors/jcropper.rb', line 20

def crop_string
  @attachment.instance.jcropper_crop_string
end

#crop_string?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/paperclip_processors/jcropper.rb', line 24

def crop_string?
  not crop_string.blank?
end

#transformation_commandObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/paperclip_processors/jcropper.rb', line 3

def transformation_command
  scale, crop = @current_geometry.transformation_to(@target_geometry, crop?)
  trans = ''
  if crop_string?
    trans << " #{crop_string}"
    trans << " -resize \"#{scale}\""
  else
    trans << " -resize \"#{scale}\""
    trans << " -crop \"#{crop}\" +repage" if crop
    trans.sub!('-crop', '-gravity North -crop') # add north gravity
    trans.sub!(/\d+\+\d+"/, '0+0"') # remove calculated offset
  end
  trans << " #{convert_options}" if convert_options?
  puts trans
  trans
end