Class: ImageProcessors::KskCrop
- Inherits:
-
Processor
- Object
- Processor
- ImageProcessors::KskCrop
- Defined in:
- lib/image_processors/ksk_crop.rb
Instance Method Summary collapse
-
#initialize(file, options = {}, attachment = nil) ⇒ KskCrop
constructor
A new instance of KskCrop.
- #make ⇒ Object
Constructor Details
#initialize(file, options = {}, attachment = nil) ⇒ KskCrop
Returns a new instance of KskCrop.
5 6 7 8 9 10 |
# File 'lib/image_processors/ksk_crop.rb', line 5 def initialize(file, = {}, = nil) super @crop = @format = File.extname(@file.path) @basename = File.basename(@file.path, @format) end |
Instance Method Details
#make ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/image_processors/ksk_crop.rb', line 12 def make src = @file dst = Tempfile.new([@basename, @format]) dst.binmode parameters = [] parameters << ":source" parameters << "-crop '#{@crop[2]}x#{@crop[3]}+#{@crop[0]}+#{@crop[1]}'" parameters << ":dest" parameters = parameters.flatten.compact.join(' ').strip.squeeze(' ') path = if @file. && @file.[:storage] == :s3 src.url else File.(src.path) end # success = Paperclip.run('convert', parameters, source: path, dest: File.expand_path(dst.path)) dst end |