Sha256: d4ffcf07c239c230069b89cc40d01a06d695e7a75addcdad08786a3731c906c3
Contents?: true
Size: 989 Bytes
Versions: 2
Compression:
Stored size: 989 Bytes
Contents
require 'gnawrnip/photographer' module Gnawrnip::RMagick class Photographer include Gnawrnip::Photographer def initialize Kernel.require 'RMagick' rescue LoadError => e if e.message =~ /cannot load.*RMagick/ raise LoadError, "Please install the gem and add `gem 'rmagick'` to your Gemfile if you are using bundler." else raise e end end def animation(images) creator = photo_creator(images) tempfile = Tempfile.new(['gnawrnip', '.gif']) creator.write(tempfile.path) image_tag(image_base64(tempfile.path), :gif) end def single(image) animation([image]) end def photo_creator(images) paths = images.map(&:path) photos = ::Magick::ImageList.new(*paths) photos.delay = Gnawrnip.frame_interval / 10.0 unless Gnawrnip.frame_size.nil? photos.each do |p| p.scale!(*Gnawrnip.frame_size) end end photos end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gnawrnip-0.1.2 | lib/gnawrnip/rmagick/photographer.rb |
gnawrnip-0.1.1 | lib/gnawrnip/rmagick/photographer.rb |