mini_magick 4.3.3 → 4.4.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 +4 -4
- data/lib/mini_magick/image/info.rb +20 -4
- data/lib/mini_magick/image.rb +11 -3
- data/lib/mini_magick/tool.rb +28 -2
- data/lib/mini_magick/version.rb +2 -2
- data/lib/mini_magick.rb +1 -0
- 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: 7f0d6f6689137d1749757919b43718103e708beb
|
|
4
|
+
data.tar.gz: 310371ca24dc3ab384f2eaff5dcfc2053cdf0d99
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bbaa819729b8f53bd43cfbc3f3d82bba32ca50d6f76730176ec99239ecf519752962f1040b11b5fbca17d4d092f9ddd362aa0e87aab62410043cc2375c6e2bc2
|
|
7
|
+
data.tar.gz: 1a3163bcc33173731cd6c0d22e3b0cf2a54c3516426dc72bf2eb67826f5efc431af8b8ea1af6435539d4a035b70466728448e1d00d63685a785d79d3870d40e2
|
|
@@ -40,12 +40,15 @@ module MiniMagick
|
|
|
40
40
|
@info.fetch(value) do
|
|
41
41
|
format, width, height, size = self["%m %w %h %b"].split(" ")
|
|
42
42
|
|
|
43
|
+
path = @path
|
|
44
|
+
path = path.match(/\[\d+\]$/).pre_match if path =~ /\[\d+\]$/
|
|
45
|
+
|
|
43
46
|
@info.update(
|
|
44
47
|
"format" => format,
|
|
45
48
|
"width" => Integer(width),
|
|
46
49
|
"height" => Integer(height),
|
|
47
50
|
"dimensions" => [Integer(width), Integer(height)],
|
|
48
|
-
"size" => File.size(
|
|
51
|
+
"size" => File.size(path),
|
|
49
52
|
"human_size" => size,
|
|
50
53
|
)
|
|
51
54
|
|
|
@@ -103,9 +106,19 @@ module MiniMagick
|
|
|
103
106
|
details_string = identify(&:verbose)
|
|
104
107
|
key_stack = []
|
|
105
108
|
details_string.lines.to_a[1..-1].each_with_object({}) do |line, details_hash|
|
|
106
|
-
next if line.strip.length.zero?
|
|
109
|
+
next if !line.valid_encoding? || line.strip.length.zero?
|
|
110
|
+
|
|
107
111
|
level = line[/^\s*/].length / 2 - 1
|
|
108
|
-
|
|
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
|
|
109
122
|
|
|
110
123
|
key, _, value = line.partition(/:[\s\n]/).map(&:strip)
|
|
111
124
|
hash = key_stack.inject(details_hash) { |hash, key| hash.fetch(key) }
|
|
@@ -120,9 +133,12 @@ module MiniMagick
|
|
|
120
133
|
end
|
|
121
134
|
|
|
122
135
|
def identify
|
|
136
|
+
path = @path
|
|
137
|
+
path += "[0]" unless path =~ /\[\d+\]$/
|
|
138
|
+
|
|
123
139
|
MiniMagick::Tool::Identify.new do |builder|
|
|
124
140
|
yield builder if block_given?
|
|
125
|
-
builder <<
|
|
141
|
+
builder << path
|
|
126
142
|
end
|
|
127
143
|
end
|
|
128
144
|
|
data/lib/mini_magick/image.rb
CHANGED
|
@@ -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 <<
|
|
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
|
|
@@ -391,7 +399,7 @@ module MiniMagick
|
|
|
391
399
|
end
|
|
392
400
|
|
|
393
401
|
def respond_to_missing?(method_name, include_private = false)
|
|
394
|
-
|
|
402
|
+
MiniMagick::Tool::Mogrify.option_methods.include?(method_name.to_s)
|
|
395
403
|
end
|
|
396
404
|
|
|
397
405
|
##
|
data/lib/mini_magick/tool.rb
CHANGED
|
@@ -16,8 +16,8 @@ module MiniMagick
|
|
|
16
16
|
class Tool
|
|
17
17
|
|
|
18
18
|
CREATION_OPERATORS = %w[
|
|
19
|
-
xc canvas logo rose gradient radial-gradient plasma
|
|
20
|
-
|
|
19
|
+
xc canvas logo rose gradient radial-gradient plasma pattern label caption
|
|
20
|
+
text
|
|
21
21
|
]
|
|
22
22
|
|
|
23
23
|
##
|
|
@@ -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
|
#
|
|
@@ -204,6 +214,22 @@ module MiniMagick
|
|
|
204
214
|
true
|
|
205
215
|
end
|
|
206
216
|
|
|
217
|
+
def self.option_methods
|
|
218
|
+
@option_methods ||= (
|
|
219
|
+
tool = new
|
|
220
|
+
tool << "-help"
|
|
221
|
+
help_page = tool.call(false, stderr: false)
|
|
222
|
+
|
|
223
|
+
cli_options = help_page.scan(/^\s+-[a-z\-]+/).map(&:strip)
|
|
224
|
+
if tool.name == "mogrify" && MiniMagick.graphicsmagick?
|
|
225
|
+
# These options were undocumented before 2015-06-14 (see gm bug 302)
|
|
226
|
+
cli_options |= %w[-box -convolve -gravity -linewidth -mattecolor -render -shave]
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
cli_options.map { |o| o[1..-1].tr('-','_') }
|
|
230
|
+
)
|
|
231
|
+
end
|
|
232
|
+
|
|
207
233
|
end
|
|
208
234
|
end
|
|
209
235
|
|
data/lib/mini_magick/version.rb
CHANGED
data/lib/mini_magick.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.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:
|
|
16
|
+
date: 2016-02-06 00:00:00.000000000 Z
|
|
17
17
|
dependencies:
|
|
18
18
|
- !ruby/object:Gem::Dependency
|
|
19
19
|
name: rake
|