Sha256: 08fe4a744a58936dabf045b768af9340afb5c49b1fdd68d80f0055db6c760d73

Contents?: true

Size: 593 Bytes

Versions: 1

Compression:

Stored size: 593 Bytes

Contents

require 'tmpdir'

module Thwomp
  class AnimationPreview

    # TODO: (optional) use Thumbnail class to make png's from the
    # rendered frames, instead of passing the frames directly to 'convert'

    attr_reader :frames

    def initialize(frames)
      @frames = frames
    end

    def generate!
      filename = "#{Dir.tmpdir}/animation_#{Time.now.to_i}.gif"
      Command.exec("convert #{frames.join(' ')} #{filename}")
      filename
    end

    # returns the gif binary data of generated animation
    def gif_data
      File.open(generate!, 'rb') { |f| f.read }
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thwomp-0.1.0 lib/thwomp/animation_preview.rb