mini_magick 4.1.0 → 4.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8921e089d8d63d1391e76876bc63b4e3ff953706
4
- data.tar.gz: 38930195578ded9545d86b4225718671a9cd8b6a
3
+ metadata.gz: 21f140f463e39c25ff85d153dde2633ae64253fc
4
+ data.tar.gz: 09fcec5741441ab2b4d7f8346ddfa2d6d5c40a51
5
5
  SHA512:
6
- metadata.gz: 39cc0fccd098a964a02be8e2cde7565d492ab9a5831df89a2f1b90d751d67368c13584c05ef3253aab51f8aecf107a52ca489a6849bd32e80a334869500f4628
7
- data.tar.gz: 9c620a81d8b8e601a172d3b8333f4020048e2b7d385ce40fe85caff7f6df7480f1e08c8046d8fa10d66164eb264efe06d9303f111444f55c6193546ca34ab0f2
6
+ metadata.gz: 6daee1a467de3117d0278a79d6006446c35bcf64afc746fa7ae04a45ee53b26334c171d7f73e58e0de97792496d82e4a00c336511e62427c55bb97e67f278f40
7
+ data.tar.gz: 87a1ccb4e52bbfd6fcfe4f4251f4d6711dd79aaa4d935b10d35c04db27ff11236dfca5422efb67c704c6953e54939751d4419cf1ca9d0bc63d91787b473ad3d3
@@ -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
 
@@ -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.
@@ -424,7 +429,7 @@ module MiniMagick
424
429
  #
425
430
  # @see http://www.imagemagick.org/script/composite.php
426
431
  #
427
- def composite(other_image, output_extension = 'jpg', mask = nil)
432
+ def composite(other_image, output_extension = type.downcase, mask = nil)
428
433
  output_tempfile = MiniMagick::Utilities.tempfile(".#{output_extension}")
429
434
 
430
435
  MiniMagick::Tool::Composite.new do |composite|
@@ -8,7 +8,7 @@ module MiniMagick
8
8
 
9
9
  module VERSION
10
10
  MAJOR = 4
11
- MINOR = 1
11
+ MINOR = 2
12
12
  TINY = 0
13
13
  PRE = nil
14
14
 
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.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Johnson
@@ -9,10 +9,11 @@ authors:
9
9
  - Peter Kieltyka
10
10
  - James Miller
11
11
  - Thiago Fernandes Massa
12
+ - Janko Marohnić
12
13
  autorequire:
13
14
  bindir: bin
14
15
  cert_chain: []
15
- date: 2015-02-17 00:00:00.000000000 Z
16
+ date: 2015-03-20 00:00:00.000000000 Z
16
17
  dependencies:
17
18
  - !ruby/object:Gem::Dependency
18
19
  name: rake
@@ -63,6 +64,7 @@ email:
63
64
  - peter@nulayer.com
64
65
  - bensie@gmail.com
65
66
  - thiagown@gmail.com
67
+ - janko.marohnic@gmail.com
66
68
  executables: []
67
69
  extensions: []
68
70
  extra_rdoc_files: []