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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78acf506ba07f56b8e32f89c777a48334ba086e8
4
- data.tar.gz: f9b867c3f49ba558960125835a37b5ea309f3886
3
+ metadata.gz: 21f140f463e39c25ff85d153dde2633ae64253fc
4
+ data.tar.gz: 09fcec5741441ab2b4d7f8346ddfa2d6d5c40a51
5
5
  SHA512:
6
- metadata.gz: 634261b16f1f3eeef52b2b2c865f6fc827df73960d9ca8af7186aeee28c950d960c98334ed9232b4b927ff597ccd1647ab97f5b1de57164b9ace46f1609c97e9
7
- data.tar.gz: dbba735b66f4afb6bb186a8d6c68ef8f14a95d55c29dbccbafbc554b8f18b7f37578578c095357e105a824dc090e41f38c7e75c02a1057885d45dab81bd37481
6
+ metadata.gz: 6daee1a467de3117d0278a79d6006446c35bcf64afc746fa7ae04a45ee53b26334c171d7f73e58e0de97792496d82e4a00c336511e62427c55bb97e67f278f40
7
+ data.tar.gz: 87a1ccb4e52bbfd6fcfe4f4251f4d6711dd79aaa4d935b10d35c04db27ff11236dfca5422efb67c704c6953e54939751d4419cf1ca9d0bc63d91787b473ad3d3
@@ -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.fetch("colorspace") do
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.fetch("exif") do
78
+ @info["exif"] ||= (
79
79
  output = self["%[EXIF:*]"]
80
80
  pairs = output.gsub(/^exif:/, "").split("\n").map { |line| line.split("=") }
81
- exif = Hash[pairs].tap do |hash|
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
- key = "raw:#{value}"
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.fetch("signature") do
103
- @info["signature"] = self["%#"]
104
- end
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
 
@@ -8,8 +8,8 @@ module MiniMagick
8
8
 
9
9
  module VERSION
10
10
  MAJOR = 4
11
- MINOR = 1
12
- TINY = 1
11
+ MINOR = 2
12
+ TINY = 0
13
13
  PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
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.1.1
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-19 00:00:00.000000000 Z
16
+ date: 2015-03-20 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rake