mini_magick 4.1.1 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of mini_magick might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/mini_magick/image.rb +5 -0
- data/lib/mini_magick/image/info.rb +33 -16
- data/lib/mini_magick/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21f140f463e39c25ff85d153dde2633ae64253fc
|
4
|
+
data.tar.gz: 09fcec5741441ab2b4d7f8346ddfa2d6d5c40a51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6daee1a467de3117d0278a79d6006446c35bcf64afc746fa7ae04a45ee53b26334c171d7f73e58e0de97792496d82e4a00c336511e62427c55bb97e67f278f40
|
7
|
+
data.tar.gz: 87a1ccb4e52bbfd6fcfe4f4251f4d6711dd79aaa4d935b10d35c04db27ff11236dfca5422efb67c704c6953e54939751d4419cf1ca9d0bc63d91787b473ad3d3
|
data/lib/mini_magick/image.rb
CHANGED
@@ -258,6 +258,11 @@ module MiniMagick
|
|
258
258
|
# @return [String]
|
259
259
|
#
|
260
260
|
attribute :signature
|
261
|
+
##
|
262
|
+
# Returns the information from `identify -verbose` in a Hash format.
|
263
|
+
#
|
264
|
+
# @return [Hash]
|
265
|
+
attribute :details
|
261
266
|
|
262
267
|
##
|
263
268
|
# Use this method if you want to access raw Identify's format API.
|
@@ -25,6 +25,8 @@ module MiniMagick
|
|
25
25
|
raw_exif(value)
|
26
26
|
when "exif"
|
27
27
|
exif
|
28
|
+
when "details"
|
29
|
+
details
|
28
30
|
else
|
29
31
|
raw(value)
|
30
32
|
end
|
@@ -53,9 +55,7 @@ module MiniMagick
|
|
53
55
|
end
|
54
56
|
|
55
57
|
def colorspace
|
56
|
-
@info
|
57
|
-
@info["colorspace"] = self["%r"]
|
58
|
-
end
|
58
|
+
@info["colorspace"] ||= self["%r"]
|
59
59
|
end
|
60
60
|
|
61
61
|
def mime_type
|
@@ -75,10 +75,10 @@ module MiniMagick
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def exif
|
78
|
-
@info
|
78
|
+
@info["exif"] ||= (
|
79
79
|
output = self["%[EXIF:*]"]
|
80
80
|
pairs = output.gsub(/^exif:/, "").split("\n").map { |line| line.split("=") }
|
81
|
-
|
81
|
+
Hash[pairs].tap do |hash|
|
82
82
|
ASCII_ENCODED_EXIF_KEYS.each do |key|
|
83
83
|
next unless hash.has_key?(key)
|
84
84
|
|
@@ -86,22 +86,40 @@ module MiniMagick
|
|
86
86
|
hash[key] = decode_comma_separated_ascii_characters(value)
|
87
87
|
end
|
88
88
|
end
|
89
|
-
|
90
|
-
@info["exif"] = exif
|
91
|
-
end
|
89
|
+
)
|
92
90
|
end
|
93
91
|
|
94
92
|
def raw(value)
|
95
|
-
|
96
|
-
@info.fetch(key) do
|
97
|
-
@info[key] = identify { |b| b.format(value) }
|
98
|
-
end
|
93
|
+
@info["raw:#{value}"] ||= identify { |b| b.format(value) }
|
99
94
|
end
|
100
95
|
|
101
96
|
def signature
|
102
|
-
@info
|
103
|
-
|
104
|
-
|
97
|
+
@info["signature"] ||= self["%#"]
|
98
|
+
end
|
99
|
+
|
100
|
+
def details
|
101
|
+
@info["details"] ||= (
|
102
|
+
details_string = identify(&:verbose)
|
103
|
+
details_string.each_line.with_object([]).inject({}) do |details_hash, (line, key_stack)|
|
104
|
+
level = line[/^\s*/].length / 2 - 1
|
105
|
+
next details_hash if level == -1 # we ignore the root level
|
106
|
+
hash = key_stack.inject(details_hash) { |hash, key| hash.fetch(key) }
|
107
|
+
key, value = line.split(":", 2).map(&:strip)
|
108
|
+
|
109
|
+
if level == key_stack.size
|
110
|
+
if value.empty?
|
111
|
+
hash[key] = {}
|
112
|
+
key_stack.push key
|
113
|
+
else
|
114
|
+
hash[key] = value
|
115
|
+
end
|
116
|
+
elsif level < key_stack.size
|
117
|
+
key_stack.pop
|
118
|
+
end
|
119
|
+
|
120
|
+
details_hash
|
121
|
+
end
|
122
|
+
)
|
105
123
|
end
|
106
124
|
|
107
125
|
def identify
|
@@ -113,7 +131,6 @@ module MiniMagick
|
|
113
131
|
|
114
132
|
def decode_comma_separated_ascii_characters(encoded_value)
|
115
133
|
return encoded_value unless encoded_value.include?(',')
|
116
|
-
|
117
134
|
encoded_value.scan(/\d+/).map(&:to_i).map(&:chr).join
|
118
135
|
end
|
119
136
|
|
data/lib/mini_magick/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_magick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Johnson
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2015-03-
|
16
|
+
date: 2015-03-20 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: rake
|