image_size 1.3.1 → 1.4.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.
- checksums.yaml +9 -9
- data/image_size.gemspec +2 -2
- data/lib/image_size.rb +7 -0
- data/spec/image_size_spec.rb +19 -17
- data/spec/test.cur +0 -0
- data/spec/test.ico +0 -0
- metadata +11 -7
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MGIyMzZhMDAxMjI3NjllMTM1ODUyNzZjYWI5NmU3OGRiNjliMGRlMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
7
|
-
|
6
|
+
MjI1MTRkYzM2YWIyODA5OGFhZjQxMTA1YmEzYmEwYzBlZmUxZmNmYg==
|
7
|
+
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWM2ZmNmOWQzZjI2ODVhYWNlNWQ0OTBmY2FhYjE4NWE2ZGMxZjljNmY3M2M5
|
10
|
+
ZWRkZGYwN2MzZTUwOWYzMTg0MWViYjQyNzc5NzBiYjY0YTFmYmVmYjk5MGRl
|
11
|
+
OTMxMzY2NjA3NDdiNzYxYmVjZTViZTZmYmNjZGViMzVhYTM0YWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzFlNjU2MWFiOTkwMjNhOGMyZjhiYWQxZmM0ZGY0YTczYTg5OTc4OTc5MzQw
|
14
|
+
Zjg4ZGY0MGFjYjlmNzdjMGZjOGFkYmIwMjA3Yzc2NDMwMzI5NGFiMzQ2ZDAy
|
15
|
+
MWRkMWFjNDY2MjA4YWIyMmM3ZjAyZjQ1MjAwMDBjYjEzNTkzYzY=
|
data/image_size.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'image_size'
|
5
|
-
s.version = '1.
|
5
|
+
s.version = '1.4.0'
|
6
6
|
s.summary = %q{Measure image size using pure Ruby}
|
7
7
|
s.description = %q{Measure following file dimensions: bmp, gif, jpeg, pbm, pcx, pgm, png, ppm, psd, swf, tiff, xbm, xpm}
|
8
8
|
s.homepage = "http://github.com/toy/#{s.name}"
|
@@ -16,5 +16,5 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
s.require_paths = %w[lib]
|
18
18
|
|
19
|
-
s.add_development_dependency 'rspec'
|
19
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
20
20
|
end
|
data/lib/image_size.rb
CHANGED
@@ -111,6 +111,8 @@ private
|
|
111
111
|
head =~ /<\?xml|<!--/ && ir[0, 4096][SVG_R]
|
112
112
|
then :svg
|
113
113
|
when head[0, 2] =~ /\n[\000-\005]/ then :pcx
|
114
|
+
when head[0, 4] == "\000\000\001\000" then :ico
|
115
|
+
when head[0, 4] == "\000\000\002\000" then :cur
|
114
116
|
end
|
115
117
|
end
|
116
118
|
|
@@ -261,4 +263,9 @@ private
|
|
261
263
|
end
|
262
264
|
end
|
263
265
|
end
|
266
|
+
|
267
|
+
def size_of_ico(ir)
|
268
|
+
ir[6, 2].unpack('CC').map{ |v| v.zero? ? 256 : v }
|
269
|
+
end
|
270
|
+
alias_method :size_of_cur, :size_of_ico
|
264
271
|
end
|
data/spec/image_size_spec.rb
CHANGED
@@ -20,6 +20,8 @@ describe ImageSize do
|
|
20
20
|
['test.xbm', :xbm, 16, 32],
|
21
21
|
['test.xpm', :xpm, 24, 32],
|
22
22
|
['test.svg', :svg, 72, 100],
|
23
|
+
['test.ico', :ico, 256, 27],
|
24
|
+
['test.cur', :cur, 50, 256],
|
23
25
|
['image_size_spec.rb', nil, nil, nil],
|
24
26
|
].each do |name, format, width, height|
|
25
27
|
path = File.join(File.dirname(__FILE__), name)
|
@@ -28,25 +30,25 @@ describe ImageSize do
|
|
28
30
|
it "should get format and dimensions for #{name} given IO" do
|
29
31
|
File.open(path, 'rb') do |fh|
|
30
32
|
is = ImageSize.new(fh)
|
31
|
-
[is.format, is.width, is.height].
|
32
|
-
fh.
|
33
|
+
expect([is.format, is.width, is.height]).to eq([format, width, height])
|
34
|
+
expect(fh).not_to be_closed
|
33
35
|
fh.rewind
|
34
|
-
fh.read.
|
36
|
+
expect(fh.read).to eq(file_data)
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
40
|
it "should get format and dimensions for #{name} given StringIO" do
|
39
41
|
io = StringIO.new(file_data)
|
40
42
|
is = ImageSize.new(io)
|
41
|
-
[is.format, is.width, is.height].
|
42
|
-
io.
|
43
|
+
expect([is.format, is.width, is.height]).to eq([format, width, height])
|
44
|
+
expect(io).not_to be_closed
|
43
45
|
io.rewind
|
44
|
-
io.read.
|
46
|
+
expect(io.read).to eq(file_data)
|
45
47
|
end
|
46
48
|
|
47
49
|
it "should get format and dimensions for #{name} given file data" do
|
48
50
|
is = ImageSize.new(file_data)
|
49
|
-
[is.format, is.width, is.height].
|
51
|
+
expect([is.format, is.width, is.height]).to eq([format, width, height])
|
50
52
|
end
|
51
53
|
|
52
54
|
it "should get format and dimensions for #{name} given Tempfile" do
|
@@ -55,32 +57,32 @@ describe ImageSize do
|
|
55
57
|
tf.write(file_data)
|
56
58
|
tf.rewind
|
57
59
|
is = ImageSize.new(tf)
|
58
|
-
[is.format, is.width, is.height].
|
59
|
-
tf.
|
60
|
+
expect([is.format, is.width, is.height]).to eq([format, width, height])
|
61
|
+
expect(tf).not_to be_closed
|
60
62
|
tf.rewind
|
61
|
-
tf.read.
|
63
|
+
expect(tf.read).to eq(file_data)
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
65
67
|
it "should get format and dimensions for #{name} given IO when run twice" do
|
66
68
|
File.open(path, 'rb') do |fh|
|
67
69
|
is = ImageSize.new(fh)
|
68
|
-
[is.format, is.width, is.height].
|
70
|
+
expect([is.format, is.width, is.height]).to eq([format, width, height])
|
69
71
|
is = ImageSize.new(fh)
|
70
|
-
[is.format, is.width, is.height].
|
72
|
+
expect([is.format, is.width, is.height]).to eq([format, width, height])
|
71
73
|
end
|
72
74
|
end
|
73
75
|
|
74
76
|
it "should get format and dimensions for #{name} as path" do
|
75
77
|
is = ImageSize.path(path)
|
76
|
-
[is.format, is.width, is.height].
|
78
|
+
expect([is.format, is.width, is.height]).to eq([format, width, height])
|
77
79
|
end
|
78
80
|
end
|
79
81
|
|
80
82
|
it "should raise ArgumentError if argument is not valid" do
|
81
|
-
|
83
|
+
expect {
|
82
84
|
ImageSize.new(Object)
|
83
|
-
}.
|
85
|
+
}.to raise_error(ArgumentError)
|
84
86
|
end
|
85
87
|
|
86
88
|
{
|
@@ -88,9 +90,9 @@ describe ImageSize do
|
|
88
90
|
:jpeg => "\377\330",
|
89
91
|
}.each do |type, data|
|
90
92
|
it "should raise FormatError if invalid #{type} given" do
|
91
|
-
|
93
|
+
expect {
|
92
94
|
ImageSize.new(data)
|
93
|
-
}.
|
95
|
+
}.to raise_error(ImageSize::FormatError)
|
94
96
|
end
|
95
97
|
end
|
96
98
|
end
|
data/spec/test.cur
ADDED
Binary file
|
data/spec/test.ico
ADDED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: image_size
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keisuke Minami
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-11-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ~>
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '0'
|
20
|
+
version: '3.0'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '0'
|
27
|
+
version: '3.0'
|
28
28
|
description: ! 'Measure following file dimensions: bmp, gif, jpeg, pbm, pcx, pgm,
|
29
29
|
png, ppm, psd, swf, tiff, xbm, xpm'
|
30
30
|
email:
|
@@ -39,7 +39,9 @@ files:
|
|
39
39
|
- image_size.gemspec
|
40
40
|
- lib/image_size.rb
|
41
41
|
- spec/image_size_spec.rb
|
42
|
+
- spec/test.cur
|
42
43
|
- spec/test.gif
|
44
|
+
- spec/test.ico
|
43
45
|
- spec/test.jpg
|
44
46
|
- spec/test.pbm
|
45
47
|
- spec/test.pcx
|
@@ -75,13 +77,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
77
|
version: '0'
|
76
78
|
requirements: []
|
77
79
|
rubyforge_project: image_size
|
78
|
-
rubygems_version: 2.
|
80
|
+
rubygems_version: 2.4.3
|
79
81
|
signing_key:
|
80
82
|
specification_version: 4
|
81
83
|
summary: Measure image size using pure Ruby
|
82
84
|
test_files:
|
83
85
|
- spec/image_size_spec.rb
|
86
|
+
- spec/test.cur
|
84
87
|
- spec/test.gif
|
88
|
+
- spec/test.ico
|
85
89
|
- spec/test.jpg
|
86
90
|
- spec/test.pbm
|
87
91
|
- spec/test.pcx
|