gifanime 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 793525a004879d9e428a657c90888ec2b4c69fb0
4
+ data.tar.gz: 2ef92d6523657a7188763316586497c10f1e8b56
5
+ SHA512:
6
+ metadata.gz: 91cf8eb636a5a58616244db94b52cdd830227544b4378f2caf9c3baa938fbc7f19da293fb9c5444084345af59b17a082153914b6fdeb5711f9f12b71fd58eda2
7
+ data.tar.gz: 98572d805678f7ba96258e1b3f50375134ca56b3e8786c71b23005f043eb51be7fe1734e6d37b215d53a53ff613b5e471e1ee9a3605edd7fe9521a92701d0ba6
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem "rspec"
7
+ gem "pry"
8
+ end
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ gifanime
2
+ ========
3
+
4
+ Thin wrapper for RMagick's animated GIF generator
5
+
6
+ # Setup
7
+
8
+ 1. install ImageMagick (eg. when OS X, `brew install imagemagick`)
9
+ 2. `gem install gifanime`
10
+
11
+ # Usage
12
+
13
+ ```ruby
14
+ require "gifanime"
15
+
16
+ gifanime = Gifanime.new("/path/to/output.gif", delay: 10)
17
+ gifanime.add("/path/to/a.png")
18
+ gifanime.add("/path/to/b.jpg")
19
+ gifanime.generate! # => generates /path/to/output.gif
20
+ ```
21
+
22
+ # License
23
+ * [MIT](http://makimoto.mit-license.org)
24
+ * and you must follow also [ImageMagick's license](http://www.imagemagick.org/script/license.php).
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env rake
2
+ # coding: utf-8
3
+
4
+ require 'rubygems'
5
+ require "bundler/gem_tasks"
6
+ require 'bundler'
7
+
8
+ begin
9
+ Bundler.setup(:default, :development)
10
+ rescue Bundler::BundlerError => e
11
+ $stderr.puts e.message
12
+ $stderr.puts "Run `bundle install` to install missing gems"
13
+ exit e.status_code
14
+ end
15
+
16
+ require 'rspec/core'
17
+ require 'rspec/core/rake_task'
18
+
19
+ RSpec::Core::RakeTask.new(:spec)
20
+
21
+ task :default => :spec
data/gifanime.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gifanime'
5
+ require 'gifanime/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "gifanime"
9
+ spec.version = Gifanime::VERSION
10
+ spec.authors = ["Shimpei Makimoto"]
11
+ spec.email = ["makimoto@tsuyabu.in"]
12
+ spec.description = %q{Thin wrapper for RMagick's animated GIF generate feature}
13
+ spec.summary = %q{This gem wraps RMagick's Magick::ListImage and makes easy create animated GIFs.}
14
+ spec.homepage = "https://github.com/makimoto/gifanime"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency "rmagick"
23
+ spec.add_development_dependency "rake"
24
+ end
25
+
@@ -0,0 +1,3 @@
1
+ class Gifanime
2
+ VERSION = "0.1.0"
3
+ end
data/lib/gifanime.rb ADDED
@@ -0,0 +1,29 @@
1
+ require "RMagick"
2
+ class Gifanime
3
+ attr_accessor :frames, :delay, :iterations, :scene, :ticks_per_secound, :outputfile
4
+
5
+ def initialize(outputfile, options = {})
6
+ @delay = options[:delay]
7
+ @iterations = options[:iterations]
8
+ @scene = options[:scene]
9
+ @ticks_per_secound = options[:ticks_per_secound]
10
+ outputfile = outputfile + ".gif" unless outputfile =~ /\.gif\z/
11
+ @outputfile = outputfile
12
+ @frames = []
13
+ end
14
+
15
+ def add(frame)
16
+ frames << frame
17
+ end
18
+
19
+ def generate!
20
+ gif = ::Magick::ImageList.new(*frames)
21
+ gif.delay = delay if delay
22
+ gif.iterations = iterations if iterations
23
+ gif.scene = scene if scene
24
+ gif.ticks_per_secound = ticks_per_secound if ticks_per_secound
25
+ gif.write(outputfile)
26
+ end
27
+ end
28
+
29
+ GifAnime = Gifanime
@@ -0,0 +1,37 @@
1
+ require "gifanime"
2
+ describe Gifanime do
3
+ let(:images) do
4
+ dir = File.dirname(__FILE__)
5
+ %W{
6
+ #{dir}/images/a.png
7
+ #{dir}/images/b.png
8
+ #{dir}/images/c.png
9
+ }
10
+ end
11
+
12
+ describe "#generate!" do
13
+ let(:outputfile) do
14
+ "#{File.dirname(__FILE__)}/images/output.gif"
15
+ end
16
+
17
+ let(:gifanime) do
18
+ Gifanime.new(outputfile)
19
+ end
20
+
21
+ before do
22
+ images.each do |image|
23
+ gifanime.add(image)
24
+ end
25
+ end
26
+
27
+ after do
28
+ path = Pathname.new(outputfile)
29
+ path.delete if path.exist?
30
+ end
31
+
32
+ it "generates GIF animation" do
33
+ gifanime.generate!.should be_a(::Magick::ImageList)
34
+ File.read(outputfile).should_not be_empty
35
+ end
36
+ end
37
+ end
data/spec/images/a.png ADDED
Binary file
data/spec/images/b.png ADDED
Binary file
data/spec/images/c.png ADDED
Binary file
@@ -0,0 +1,4 @@
1
+ # coding: utf-8
2
+
3
+ require 'bundler'
4
+ Bundler.setup(:default, :development)
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gifanime
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Shimpei Makimoto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rmagick
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Thin wrapper for RMagick's animated GIF generate feature
42
+ email:
43
+ - makimoto@tsuyabu.in
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - README.md
51
+ - Rakefile
52
+ - gifanime.gemspec
53
+ - lib/gifanime.rb
54
+ - lib/gifanime/version.rb
55
+ - spec/gifanime_spec.rb
56
+ - spec/images/a.png
57
+ - spec/images/b.png
58
+ - spec/images/c.png
59
+ - spec/spec_helper.rb
60
+ homepage: https://github.com/makimoto/gifanime
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.0.3
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: This gem wraps RMagick's Magick::ListImage and makes easy create animated
84
+ GIFs.
85
+ test_files:
86
+ - spec/gifanime_spec.rb
87
+ - spec/images/a.png
88
+ - spec/images/b.png
89
+ - spec/images/c.png
90
+ - spec/spec_helper.rb
91
+ has_rdoc: