Sha256: 7f9d1e5879499eb71fce3304d97e4bfa1dc30361354e4996aa3b4688e277a8ca
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
require 'tempfile' require 'mini_magick' require 'dragonfly' module Dragonfly module Minimagick module Utils include Dragonfly::Loggable private def minimagick_image(temp_object, &block) image = MiniMagick::Image.open(temp_object.path) result = block.call(image) case result when MiniMagick::Image content = write_to_tempfile(result) result.destroy! else content = result end image.destroy! content rescue Exception => e log.warn("Unable to handle content in #{self.class} - got:\n#{e}") throw :unable_to_handle end def ping_minimagick_image(temp_object, &block) image = MiniMagick::Image.open(temp_object.path) result = block.call(image) image.destroy! result rescue Exception => e log.warn("Unable to handle content in #{self.class} - got:\n#{e}") throw :unable_to_handle end def write_to_tempfile(minimagick_image) tempfile = Tempfile.new('dragonfly') tempfile.close minimagick_image.write(tempfile.path) tempfile end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dragonfly-minimagick-0.0.1 | lib/dragonfly-minimagick/utils.rb |