Sha256: 0794330b6ecbb4a71939604581e9ab734d106df692524e6b5e9a389b7d4a0907
Contents?: true
Size: 922 Bytes
Versions: 96
Compression:
Stored size: 922 Bytes
Contents
require "rvideo" class VideoThumbnailEncoder < Dragonfly::Encoding::RMagickEncoder def encode(image, format, encoding={}) format = format.to_s.downcase throw :unable_to_handle unless supported_formats.include?(format.to_sym) encoded_image = rmagick_image(image, encoding[:offset]) if encoded_image.format.downcase == format image # do nothing else encoded_image.format = format encoded_image.to_blob end end private def rmagick_image(temp_object, offset = "30%") vi = RVideo::Inspector.new(:file => temp_object.path) if vi.valid? voutput = RVideo::FrameCapturer.capture!( :input => temp_object.path, :offset => offset) Magick::Image.read(voutput).first else throw :unable_to_handle end rescue Magick::ImageMagickError => e log.warn("Unable to handle content in #{self.class} - got:\n#{e}") throw :unable_to_handle end end
Version data entries
96 entries across 96 versions & 1 rubygems