gif-info 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +33 -0
- data/LICENSE.txt +20 -0
- data/README.md +52 -0
- data/Rakefile +37 -0
- data/VERSION +1 -0
- data/ajax-loader-0.gif +0 -0
- data/ajax-loader.gif +0 -0
- data/bin/gif-dump +41 -0
- data/bin/gif-info +44 -0
- data/gif-info.gemspec +86 -0
- data/lib/gif-info.rb +407 -0
- data/lib/gif-info/block.rb +84 -0
- data/lib/gif-info/blocks/application-extension.rb +38 -0
- data/lib/gif-info/blocks/comment-extension.rb +35 -0
- data/lib/gif-info/blocks/global-color-table.rb +25 -0
- data/lib/gif-info/blocks/graphics-control-extension.rb +43 -0
- data/lib/gif-info/blocks/header-block.rb +35 -0
- data/lib/gif-info/blocks/image-data.rb +35 -0
- data/lib/gif-info/blocks/image-descriptor.rb +45 -0
- data/lib/gif-info/blocks/local-color-table.rb +25 -0
- data/lib/gif-info/blocks/logical-screen-descriptor.rb +43 -0
- data/lib/gif-info/blocks/plain-text-extension.rb +77 -0
- data/lib/gif-info/blocks/trailer.rb +32 -0
- data/lib/gif-info/body.rb +105 -0
- data/lib/gif-info/color-table.rb +32 -0
- data/lib/gif-info/data-block.rb +56 -0
- data/lib/gif-info/dynamic-block.rb +66 -0
- data/lib/gif-info/fixed-block.rb +82 -0
- data/lib/gif-info/raw-block.rb +78 -0
- data/test +112 -0
- metadata +157 -0
data/test
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
# (c) 2011 Martin Kozák (martinkozak@martinkozak.net)
|
4
|
+
|
5
|
+
$:.push("./lib")
|
6
|
+
require "gif-info"
|
7
|
+
require "riot"
|
8
|
+
require "digest/md5"
|
9
|
+
|
10
|
+
context "GifInfo (animated, base informations)" do
|
11
|
+
setup do
|
12
|
+
GifInfo::analyze_file("./ajax-loader.gif")
|
13
|
+
end
|
14
|
+
|
15
|
+
asserts("base informations accessor") do
|
16
|
+
result = true
|
17
|
+
result &= (topic.type == :GIF)
|
18
|
+
result &= (topic.version == :"89a")
|
19
|
+
result &= (topic.width == 32)
|
20
|
+
result &= (topic.height == 32)
|
21
|
+
result &= (topic.color_resolution == 64)
|
22
|
+
result &= (topic.pixel_aspect_ratio.nil?)
|
23
|
+
result &= (topic.images_count == 12)
|
24
|
+
result &= (topic.cyclic?)
|
25
|
+
result &= (topic.animated?)
|
26
|
+
result &= (not topic.interlaced?)
|
27
|
+
result &= (not topic.transparent?)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "GifInfo (animated, global structure)" do
|
32
|
+
setup do
|
33
|
+
data = Struct::new(:count, :color_tables_data, :images_data)::new(0, "", "")
|
34
|
+
File::open("./ajax-loader.gif", "rb") do |io|
|
35
|
+
GifInfo::parse(io) do |block|
|
36
|
+
data.count += 1
|
37
|
+
|
38
|
+
if [GifInfo::Blocks::GlobalColorTable, GifInfo::Blocks::LocalColorTable].include? block.class
|
39
|
+
data.color_tables_data << block.body
|
40
|
+
elsif block.kind_of? GifInfo::Blocks::ImageData
|
41
|
+
data.images_data << block.body.data
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
data
|
47
|
+
end
|
48
|
+
|
49
|
+
asserts("blocks count") do
|
50
|
+
topic.count == 42
|
51
|
+
end
|
52
|
+
|
53
|
+
asserts("color tables content") do
|
54
|
+
Digest::MD5.hexdigest(topic.color_tables_data) == "48b630060f3cc156c8b35ba58eaade5c"
|
55
|
+
end
|
56
|
+
|
57
|
+
asserts("images data") do
|
58
|
+
Digest::MD5.hexdigest(topic.images_data) == "a660b40aa42d09e3f79107edfdd4b042"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "GifInfo (unanimated, base informations)" do
|
63
|
+
setup do
|
64
|
+
GifInfo::analyze_file("./ajax-loader-0.gif")
|
65
|
+
end
|
66
|
+
|
67
|
+
asserts("base informations accessor") do
|
68
|
+
result = true
|
69
|
+
result &= (topic.type == :GIF)
|
70
|
+
result &= (topic.version == :"89a")
|
71
|
+
result &= (topic.width == 32)
|
72
|
+
result &= (topic.height == 32)
|
73
|
+
result &= (topic.color_resolution == 256)
|
74
|
+
result &= (topic.pixel_aspect_ratio.nil?)
|
75
|
+
result &= (topic.images_count == 1)
|
76
|
+
result &= (not topic.cyclic?)
|
77
|
+
result &= (not topic.animated?)
|
78
|
+
result &= (not topic.interlaced?)
|
79
|
+
result &= (not topic.transparent?)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "GifInfo (unanimated, global structure)" do
|
84
|
+
setup do
|
85
|
+
data = Struct::new(:count, :color_tables_data, :images_data)::new(0, "", "")
|
86
|
+
File::open("./ajax-loader-0.gif", "rb") do |io|
|
87
|
+
GifInfo::parse(io) do |block|
|
88
|
+
data.count += 1
|
89
|
+
|
90
|
+
if [GifInfo::Blocks::GlobalColorTable, GifInfo::Blocks::LocalColorTable].include? block.class
|
91
|
+
data.color_tables_data << block.body
|
92
|
+
elsif block.kind_of? GifInfo::Blocks::ImageData
|
93
|
+
data.images_data << block.body.data
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
data
|
99
|
+
end
|
100
|
+
|
101
|
+
asserts("blocks count") do
|
102
|
+
topic.count == 8
|
103
|
+
end
|
104
|
+
|
105
|
+
asserts("color tables content") do
|
106
|
+
Digest::MD5.hexdigest(topic.color_tables_data) == "fc55558e8169339f09831300b068fd41"
|
107
|
+
end
|
108
|
+
|
109
|
+
asserts("images data") do
|
110
|
+
Digest::MD5.hexdigest(topic.images_data) == "e26142b66066aaa01316f14982e45dea"
|
111
|
+
end
|
112
|
+
end
|
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gif-info
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- "Martin Koz\xC3\xA1k"
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-03-10 00:00:00 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: struct-fx
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.1.1
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: abstract
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.0.0
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: frozen-objects
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.2.0
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: bundler
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 1.0.0
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: jeweler
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 1.5.2
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: *id005
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: riot
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 0.12.1
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: *id006
|
82
|
+
description:
|
83
|
+
email: martinkozak@martinkozak.net
|
84
|
+
executables:
|
85
|
+
- gif-dump
|
86
|
+
- gif-info
|
87
|
+
extensions: []
|
88
|
+
|
89
|
+
extra_rdoc_files:
|
90
|
+
- LICENSE.txt
|
91
|
+
- README.md
|
92
|
+
files:
|
93
|
+
- .document
|
94
|
+
- Gemfile
|
95
|
+
- Gemfile.lock
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- VERSION
|
100
|
+
- ajax-loader-0.gif
|
101
|
+
- ajax-loader.gif
|
102
|
+
- bin/gif-dump
|
103
|
+
- bin/gif-info
|
104
|
+
- gif-info.gemspec
|
105
|
+
- lib/gif-info.rb
|
106
|
+
- lib/gif-info/block.rb
|
107
|
+
- lib/gif-info/blocks/application-extension.rb
|
108
|
+
- lib/gif-info/blocks/comment-extension.rb
|
109
|
+
- lib/gif-info/blocks/global-color-table.rb
|
110
|
+
- lib/gif-info/blocks/graphics-control-extension.rb
|
111
|
+
- lib/gif-info/blocks/header-block.rb
|
112
|
+
- lib/gif-info/blocks/image-data.rb
|
113
|
+
- lib/gif-info/blocks/image-descriptor.rb
|
114
|
+
- lib/gif-info/blocks/local-color-table.rb
|
115
|
+
- lib/gif-info/blocks/logical-screen-descriptor.rb
|
116
|
+
- lib/gif-info/blocks/plain-text-extension.rb
|
117
|
+
- lib/gif-info/blocks/trailer.rb
|
118
|
+
- lib/gif-info/body.rb
|
119
|
+
- lib/gif-info/color-table.rb
|
120
|
+
- lib/gif-info/data-block.rb
|
121
|
+
- lib/gif-info/dynamic-block.rb
|
122
|
+
- lib/gif-info/fixed-block.rb
|
123
|
+
- lib/gif-info/raw-block.rb
|
124
|
+
- test
|
125
|
+
has_rdoc: true
|
126
|
+
homepage: http://github.com/martinkozak/gif-info
|
127
|
+
licenses:
|
128
|
+
- MIT
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
hash: -1013647067280151618
|
140
|
+
segments:
|
141
|
+
- 0
|
142
|
+
version: "0"
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: "0"
|
149
|
+
requirements: []
|
150
|
+
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 1.6.2
|
153
|
+
signing_key:
|
154
|
+
specification_version: 3
|
155
|
+
summary: Pure Ruby analyzer of the GIF image format. Performs complete analysis of internal GIF block structure and streams it as an objects stream with metainformations of each block. Also can interpret internal structure by providing the simple object-like interface to base image file informations. Works above seekable IO streams, so allows processing of the big files too. Doesn't perform LZW decompressing, returns raw data for both color tables and images.
|
156
|
+
test_files: []
|
157
|
+
|