Sha256: 4904e800e2e08b46e679597834607239d7389eeb4cd9dd931fe28b0df93b094d

Contents?: true

Size: 475 Bytes

Versions: 9

Compression:

Stored size: 475 Bytes

Contents

module RailsAdminJcrop
  module ImageHelper

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

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

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

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ack_rails_admin_jcrop-0.0.10 lib/rails_admin_jcrop/image_helper.rb
ack_rails_admin_jcrop-0.0.9 lib/rails_admin_jcrop/image_helper.rb
ack_rails_admin_jcrop-0.0.7 lib/rails_admin_jcrop/image_helper.rb
ack_rails_admin_jcrop-0.0.6 lib/rails_admin_jcrop/image_helper.rb
ack_rails_admin_jcrop-0.0.5 lib/rails_admin_jcrop/image_helper.rb
ack_rails_admin_jcrop-0.0.4 lib/rails_admin_jcrop/image_helper.rb
ack_rails_admin_jcrop-0.0.3 lib/rails_admin_jcrop/image_helper.rb
ack_rails_admin_jcrop-0.0.2 lib/rails_admin_jcrop/image_helper.rb
ack_rails_admin_jcrop-0.0.1 lib/rails_admin_jcrop/image_helper.rb