Sha256: b07fb20741e24270fa406e469f085a96fbb9e7ffda94565580688b6b117b30b8

Contents?: true

Size: 865 Bytes

Versions: 19

Compression:

Stored size: 865 Bytes

Contents

module Paperclip
  
  class KskCrop < Processor
    
    def initialize(file, options = {}, attachment = nil)
      super
      @crop = options
      @format = File.extname(@file.path)
      @basename = File.basename(@file.path, @format)
    end
    
    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.options && @file.options[:storage] == :s3
        src.url
      else
        File.expand_path(src.path)
      end
      success = Paperclip.run('convert', parameters, source: path, dest: File.expand_path(dst.path))

      dst
    end
    
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ksk-0.4.7 lib/paperclip_processors/ksk_crop.rb
ksk-0.4.6 lib/paperclip_processors/ksk_crop.rb
ksk-0.4.5 lib/paperclip_processors/ksk_crop.rb
ksk-0.4.4 lib/paperclip_processors/ksk_crop.rb
ksk-0.4.3 lib/paperclip_processors/ksk_crop.rb
ksk-0.4.2 lib/paperclip_processors/ksk_crop.rb
ksk-0.4.1 lib/paperclip_processors/ksk_crop.rb
ksk-0.4.0 lib/paperclip_processors/ksk_crop.rb
ksk-0.3.4 lib/paperclip_processors/ksk_crop.rb
ksk-0.3.3 lib/paperclip_processors/ksk_crop.rb
ksk-0.3.2 lib/paperclip_processors/ksk_crop.rb
ksk-0.3.0 lib/paperclip_processors/ksk_crop.rb
ksk-0.2.15 lib/paperclip_processors/ksk_crop.rb
ksk-0.2.14 lib/paperclip_processors/ksk_crop.rb
ksk-0.2.13 lib/paperclip_processors/ksk_crop.rb
ksk-0.2.12 lib/paperclip_processors/ksk_crop.rb
ksk-0.2.11 lib/paperclip_processors/ksk_crop.rb
ksk-0.2.10 lib/paperclip_processors/ksk_crop.rb
ksk-0.2.9 lib/paperclip_processors/ksk_crop.rb