mini_magick 4.3.1 → 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 +15 -8
- 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.
|
|
@@ -332,17 +336,19 @@ module MiniMagick
|
|
|
332
336
|
# @return [self]
|
|
333
337
|
#
|
|
334
338
|
def format(format, page = 0)
|
|
335
|
-
@info.clear
|
|
336
|
-
|
|
337
339
|
if @tempfile
|
|
338
340
|
new_tempfile = MiniMagick::Utilities.tempfile(".#{format}")
|
|
339
341
|
new_path = new_tempfile.path
|
|
340
342
|
else
|
|
341
|
-
new_path = path.sub(
|
|
343
|
+
new_path = path.sub(/(\.\w+)?$/, ".#{format}")
|
|
344
|
+
new_path.sub!(/\[(\d+)\]/, '_\1') if layer?
|
|
342
345
|
end
|
|
343
346
|
|
|
347
|
+
input_path = path.dup
|
|
348
|
+
input_path << "[#{page}]" if page && !layer?
|
|
349
|
+
|
|
344
350
|
MiniMagick::Tool::Convert.new do |convert|
|
|
345
|
-
convert <<
|
|
351
|
+
convert << input_path
|
|
346
352
|
yield convert if block_given?
|
|
347
353
|
convert << new_path
|
|
348
354
|
end
|
|
@@ -351,10 +357,11 @@ module MiniMagick
|
|
|
351
357
|
@tempfile.unlink
|
|
352
358
|
@tempfile = new_tempfile
|
|
353
359
|
else
|
|
354
|
-
File.delete(path) unless path == new_path
|
|
360
|
+
File.delete(path) unless path == new_path || layer?
|
|
355
361
|
end
|
|
356
362
|
|
|
357
363
|
path.replace new_path
|
|
364
|
+
@info.clear
|
|
358
365
|
|
|
359
366
|
self
|
|
360
367
|
end
|
|
@@ -392,7 +399,7 @@ module MiniMagick
|
|
|
392
399
|
end
|
|
393
400
|
|
|
394
401
|
def respond_to_missing?(method_name, include_private = false)
|
|
395
|
-
|
|
402
|
+
MiniMagick::Tool::Mogrify.option_methods.include?(method_name.to_s)
|
|
396
403
|
end
|
|
397
404
|
|
|
398
405
|
##
|
|
@@ -492,8 +499,6 @@ module MiniMagick
|
|
|
492
499
|
end
|
|
493
500
|
|
|
494
501
|
def mogrify(page = nil)
|
|
495
|
-
@info.clear
|
|
496
|
-
|
|
497
502
|
MiniMagick::Tool::Mogrify.new do |builder|
|
|
498
503
|
builder.instance_eval do
|
|
499
504
|
def format(*args)
|
|
@@ -505,6 +510,8 @@ module MiniMagick
|
|
|
505
510
|
builder << (page ? "#{path}[#{page}]" : path)
|
|
506
511
|
end
|
|
507
512
|
|
|
513
|
+
@info.clear
|
|
514
|
+
|
|
508
515
|
self
|
|
509
516
|
end
|
|
510
517
|
|
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
|