image_size 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +1 -0
- data/.travis.yml +12 -0
- data/Gemfile +3 -0
- data/README.markdown +2 -0
- data/image_size.gemspec +1 -1
- data/lib/image_size.rb +3 -2
- data/spec/image_size_spec.rb +16 -9
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjNlM2Y5M2U0NTk4M2NjNGQ2MWM2OWZjYjVmMWJkODcxZTVhYjI4Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjY0NTc4ZDRjNjkwNWFlZmM5NDk1NmIwYWFjYjI1YzkyOGU2N2Q5Mw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2MzNzhhOWNhOTY5ZjM2NDk0MDE5MTUzNzkwNWYyZjVkYjEwNGQ1MThkMGYw
|
10
|
+
OWY3MWRlMGY1ODgyMTk5MzRiNDExZDIyOWVkZjQzNjkxNGMyNGVlNzI3MGY0
|
11
|
+
ODhjMzA1OTljNWQyYmYxM2JlODVjY2ZmNGM3YmY1NjM5ZjNhYzE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTY1NTEwZmZmYWQ2Njk5ZWUyZWU2OWEyODlmZDAwYWJhN2UzMWZmMTkyOTk2
|
14
|
+
M2Y5YTE4N2YwZmIzNjQ5NzZlMzBmZGFjNTE0MmQwNTdlYzgyN2ZjODllZDdj
|
15
|
+
NmQxYzYzZjBkYjAyOGI1MTAzMGVhM2UxMDk2YTYxMzRiMWFlZDQ=
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.markdown
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
measure image size using pure Ruby
|
4
4
|
formats: `bmp`, `gif`, `jpeg`, `pbm`, `pcx`, `pgm`, `png`, `ppm`, `psd`, `swf`, `tiff`, `xbm`, `xpm`
|
5
5
|
|
6
|
+
[![Build Status](https://travis-ci.org/toy/image_size.png?branch=master)](https://travis-ci.org/toy/image_size)
|
7
|
+
|
6
8
|
## Download
|
7
9
|
|
8
10
|
The latest version of image\_size can be found at http://github.com/toy/image_size
|
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.1.
|
5
|
+
s.version = '1.1.4'
|
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}"
|
data/lib/image_size.rb
CHANGED
@@ -25,8 +25,9 @@ class ImageSize
|
|
25
25
|
@data = ''
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
28
|
+
def close
|
29
29
|
@io.rewind
|
30
|
+
@io.close if IO === @io
|
30
31
|
end
|
31
32
|
|
32
33
|
CHUNK = 1024
|
@@ -55,7 +56,7 @@ class ImageSize
|
|
55
56
|
if @format = detect_format(ir)
|
56
57
|
@width, @height = self.send("size_of_#{@format}", ir)
|
57
58
|
end
|
58
|
-
ir.
|
59
|
+
ir.close
|
59
60
|
end
|
60
61
|
|
61
62
|
# Image format
|
data/spec/image_size_spec.rb
CHANGED
@@ -19,35 +19,42 @@ describe ImageSize do
|
|
19
19
|
['image_size_spec.rb', nil, nil, nil],
|
20
20
|
].each do |name, format, width, height|
|
21
21
|
path = File.join(File.dirname(__FILE__), name)
|
22
|
+
file_data = File.open(path, 'rb', &:read)
|
22
23
|
|
23
24
|
it "should get format and dimensions for #{name} given IO" do
|
24
25
|
File.open(path, 'rb') do |fh|
|
25
26
|
is = ImageSize.new(fh)
|
26
27
|
[is.format, is.width, is.height].should == [format, width, height]
|
28
|
+
fh.should_not be_closed
|
29
|
+
fh.rewind
|
30
|
+
fh.read.should == file_data
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
30
34
|
it "should get format and dimensions for #{name} given StringIO" do
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
+
io = StringIO.new(file_data)
|
36
|
+
is = ImageSize.new(io)
|
37
|
+
[is.format, is.width, is.height].should == [format, width, height]
|
38
|
+
io.should_not be_closed
|
39
|
+
io.rewind
|
40
|
+
io.read.should == file_data
|
35
41
|
end
|
36
42
|
|
37
43
|
it "should get format and dimensions for #{name} given file data" do
|
38
|
-
|
39
|
-
|
40
|
-
[is.format, is.width, is.height].should == [format, width, height]
|
41
|
-
end
|
44
|
+
is = ImageSize.new(file_data)
|
45
|
+
[is.format, is.width, is.height].should == [format, width, height]
|
42
46
|
end
|
43
47
|
|
44
48
|
it "should get format and dimensions for #{name} given Tempfile" do
|
45
|
-
file_data = File.open(path, 'rb') { |fh| fh.read }
|
46
49
|
Tempfile.open(name) do |tf|
|
50
|
+
tf.binmode
|
47
51
|
tf.write(file_data)
|
48
52
|
tf.rewind
|
49
53
|
is = ImageSize.new(tf)
|
50
54
|
[is.format, is.width, is.height].should == [format, width, height]
|
55
|
+
tf.should_not be_closed
|
56
|
+
tf.rewind
|
57
|
+
tf.read.should == file_data
|
51
58
|
end
|
52
59
|
end
|
53
60
|
|
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.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keisuke Minami
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -33,6 +33,8 @@ extensions: []
|
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
35
|
- .gitignore
|
36
|
+
- .travis.yml
|
37
|
+
- Gemfile
|
36
38
|
- README.markdown
|
37
39
|
- image_size.gemspec
|
38
40
|
- lib/image_size.rb
|