image_info 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +5 -0
- data/lib/image_info/image.rb +6 -3
- data/lib/image_info/parser.rb +4 -3
- data/lib/image_info/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 335b5d988c8fec52bf9d34596062dd56ff9d4db2
|
4
|
+
data.tar.gz: 4547675b414cd13d918d5abe0349b3db7516f5cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8b7a26d43a838cb5291837e26a96c7c1bc7748c6ec86dd64a04ca00ee0f93c28c9856ea057b6e8c0ab5d8fd4b85da4c74d483b9d68425f4732df69b230e5f1a
|
7
|
+
data.tar.gz: a4385f974bffe74fd345ca38f0dd39536dde0a21db75d5426d52ecb0040246b68d03fb4f606a54aed20615cb4d2b4ed06df8f2a59a2680a83b6898065b8b6212
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
[![Code Climate](https://codeclimate.com/github/gottfrois/image_info/badges/gpa.svg)](https://codeclimate.com/github/gottfrois/image_info)
|
4
4
|
[![Build Status](https://travis-ci.org/gottfrois/image_info.svg)](https://travis-ci.org/gottfrois/image_info)
|
5
5
|
[![Dependency Status](https://gemnasium.com/gottfrois/image_info.svg)](https://gemnasium.com/gottfrois/image_info)
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/image_info.svg)](http://badge.fury.io/rb/image_info)
|
6
7
|
|
7
8
|
ImageInfo finds the size and type of a single or multiple images from the web by fetching as little as needed in batches.
|
8
9
|
|
@@ -34,6 +35,10 @@ For a single image:
|
|
34
35
|
|
35
36
|
```ruby
|
36
37
|
image = ImageInfo.from('http://foo.com/foo.png').first
|
38
|
+
image.width
|
39
|
+
=> 256
|
40
|
+
image.height
|
41
|
+
=> 256
|
37
42
|
image.size
|
38
43
|
=> [256, 256]
|
39
44
|
image.type
|
data/lib/image_info/image.rb
CHANGED
@@ -4,11 +4,14 @@ module ImageInfo
|
|
4
4
|
class Image
|
5
5
|
|
6
6
|
attr_reader :uri
|
7
|
-
attr_accessor :
|
7
|
+
attr_accessor :width, :height, :type
|
8
8
|
|
9
9
|
def initialize(uri)
|
10
|
-
@uri
|
11
|
-
|
10
|
+
@uri = ::URI.parse(uri.to_s)
|
11
|
+
end
|
12
|
+
|
13
|
+
def size
|
14
|
+
[width, height].compact
|
12
15
|
end
|
13
16
|
|
14
17
|
def valid?
|
data/lib/image_info/parser.rb
CHANGED
@@ -6,8 +6,8 @@ module ImageInfo
|
|
6
6
|
attr_reader :image, :bytes, :parser
|
7
7
|
|
8
8
|
def initialize(image, data)
|
9
|
-
@image
|
10
|
-
@bytes
|
9
|
+
@image = image
|
10
|
+
@bytes = data.bytes
|
11
11
|
@parser = ::ImageSize.new(data)
|
12
12
|
end
|
13
13
|
|
@@ -19,7 +19,8 @@ module ImageInfo
|
|
19
19
|
private
|
20
20
|
|
21
21
|
def set_image_size
|
22
|
-
image.
|
22
|
+
image.width = parser.width
|
23
|
+
image.height = parser.height
|
23
24
|
end
|
24
25
|
|
25
26
|
def set_image_type
|
data/lib/image_info/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: image_info
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre-Louis Gottfrois
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- .gitignore
|
106
106
|
- .rspec
|
107
107
|
- .travis.yml
|
108
|
+
- CHANGELOG.md
|
108
109
|
- Gemfile
|
109
110
|
- LICENSE.txt
|
110
111
|
- README.md
|