mini_magick 4.3.6 → 4.4.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: 9d7353bb4abb1f24f782090a89632e2697cc8f77
4
- data.tar.gz: ec2f0d8462829f39796474f292c4d06ef9f7ec35
3
+ metadata.gz: 7f0d6f6689137d1749757919b43718103e708beb
4
+ data.tar.gz: 310371ca24dc3ab384f2eaff5dcfc2053cdf0d99
5
5
  SHA512:
6
- metadata.gz: 9ceb0494e0c4d9f568482d2c7c8249ed91e01931ddfffd8e119df1de379e4f35343ba5c40af38daa4b021d359a3d44e4c3ab6e86e096d97487e9beb387697a55
7
- data.tar.gz: 9bba8837c2ee3f10751932dee4afcd46724392d7e04a01ee1527aacb8c7043a092e7de7067f85e194da9e8cfeeff03a4d9ec11ea04c93151e8e020983bc0bd20
6
+ metadata.gz: bbaa819729b8f53bd43cfbc3f3d82bba32ca50d6f76730176ec99239ecf519752962f1040b11b5fbca17d4d092f9ddd362aa0e87aab62410043cc2375c6e2bc2
7
+ data.tar.gz: 1a3163bcc33173731cd6c0d22e3b0cf2a54c3516426dc72bf2eb67826f5efc431af8b8ea1af6435539d4a035b70466728448e1d00d63685a785d79d3870d40e2
@@ -133,6 +133,10 @@ module MiniMagick
133
133
  # @return [String] The location of the current working file
134
134
  #
135
135
  attr_reader :path
136
+ ##
137
+ # @return [Tempfile] The underlying temporary file
138
+ #
139
+ attr_reader :tempfile
136
140
 
137
141
  ##
138
142
  # Create a new {MiniMagick::Image} object.
@@ -337,10 +341,14 @@ module MiniMagick
337
341
  new_path = new_tempfile.path
338
342
  else
339
343
  new_path = path.sub(/(\.\w+)?$/, ".#{format}")
344
+ new_path.sub!(/\[(\d+)\]/, '_\1') if layer?
340
345
  end
341
346
 
347
+ input_path = path.dup
348
+ input_path << "[#{page}]" if page && !layer?
349
+
342
350
  MiniMagick::Tool::Convert.new do |convert|
343
- convert << (page ? "#{path}[#{page}]" : path)
351
+ convert << input_path
344
352
  yield convert if block_given?
345
353
  convert << new_path
346
354
  end
@@ -349,7 +357,7 @@ module MiniMagick
349
357
  @tempfile.unlink
350
358
  @tempfile = new_tempfile
351
359
  else
352
- File.delete(path) unless path == new_path
360
+ File.delete(path) unless path == new_path || layer?
353
361
  end
354
362
 
355
363
  path.replace new_path
@@ -106,9 +106,19 @@ module MiniMagick
106
106
  details_string = identify(&:verbose)
107
107
  key_stack = []
108
108
  details_string.lines.to_a[1..-1].each_with_object({}) do |line, details_hash|
109
- next if line.strip.length.zero?
109
+ next if !line.valid_encoding? || line.strip.length.zero?
110
+
110
111
  level = line[/^\s*/].length / 2 - 1
111
- key_stack.pop until key_stack.size <= level
112
+ if level >= 0
113
+ key_stack.pop until key_stack.size <= level
114
+ else
115
+ # Some metadata, such as SVG clipping paths, will be saved without
116
+ # indentation, resulting in a level of -1
117
+ last_key = details_hash.keys.last
118
+ details_hash[last_key] = '' if details_hash[last_key].empty?
119
+ details_hash[last_key] << line
120
+ next
121
+ end
112
122
 
113
123
  key, _, value = line.partition(/:[\s\n]/).map(&:strip)
114
124
  hash = key_stack.inject(details_hash) { |hash, key| hash.fetch(key) }
@@ -185,6 +185,16 @@ module MiniMagick
185
185
  end
186
186
  end
187
187
 
188
+ ##
189
+ # This option is a valid ImageMagick option, but it's also a Ruby method,
190
+ # so we need to override it so that it correctly acts as an option method.
191
+ #
192
+ def clone(*args)
193
+ self << '-clone'
194
+ self.merge!(args)
195
+ self
196
+ end
197
+
188
198
  ##
189
199
  # Any undefined method will be transformed into a CLI option
190
200
  #
@@ -8,8 +8,8 @@ module MiniMagick
8
8
 
9
9
  module VERSION
10
10
  MAJOR = 4
11
- MINOR = 3
12
- TINY = 6
11
+ MINOR = 4
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.3.6
4
+ version: 4.4.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-10-12 00:00:00.000000000 Z
16
+ date: 2016-02-06 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rake