Module: RailsAdminJcrop::ImageHelper

Defined in:
lib/rails_admin_jcrop/image_helper.rb

Class Method Summary collapse

Class Method Details

.crop(img, w, h, x, y) ⇒ Object



5
6
7
8
# File 'lib/rails_admin_jcrop/image_helper.rb', line 5

def crop(img, w, h, x, y)
  processor = img.class.name =~ /^MiniMagick/ ? 'minimagick' : 'rmagick'
  send("#{processor}_crop", img, w, h, x, y)
end

.minimagick_crop(img, w, h, x, y) ⇒ Object



10
11
12
13
# File 'lib/rails_admin_jcrop/image_helper.rb', line 10

def minimagick_crop(img, w, h, x, y)
  geometry = "#{w}x#{h}+#{x}+#{y}"
  img.crop geometry
end

.rmagick_crop(img, w, h, x, y) ⇒ Object



15
16
17
# File 'lib/rails_admin_jcrop/image_helper.rb', line 15

def rmagick_crop(img, w, h, x, y)
  img.crop! x.to_i, y.to_i, w.to_i, h.to_i
end