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