mini_magick 4.2.10 → 4.3.6
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.
Potentially problematic release.
This version of mini_magick might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/mini_magick/configuration.rb +3 -13
- data/lib/mini_magick/image/info.rb +9 -2
- data/lib/mini_magick/image.rb +7 -12
- data/lib/mini_magick/tool.rb +39 -77
- 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: 9d7353bb4abb1f24f782090a89632e2697cc8f77
|
4
|
+
data.tar.gz: ec2f0d8462829f39796474f292c4d06ef9f7ec35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ceb0494e0c4d9f568482d2c7c8249ed91e01931ddfffd8e119df1de379e4f35343ba5c40af38daa4b021d359a3d44e4c3ab6e86e096d97487e9beb387697a55
|
7
|
+
data.tar.gz: 9bba8837c2ee3f10751932dee4afcd46724392d7e04a01ee1527aacb8c7043a092e7de7067f85e194da9e8cfeeff03a4d9ec11ea04c93151e8e020983bc0bd20
|
@@ -114,8 +114,6 @@ module MiniMagick
|
|
114
114
|
"processor has to be set to either \"mogrify\" or \"gm\"" \
|
115
115
|
", was set to #{@processor.inspect}"
|
116
116
|
end
|
117
|
-
|
118
|
-
reload_tools
|
119
117
|
end
|
120
118
|
|
121
119
|
def cli
|
@@ -131,20 +129,11 @@ module MiniMagick
|
|
131
129
|
def cli=(value)
|
132
130
|
@cli = value
|
133
131
|
|
134
|
-
|
135
|
-
when :imagemagick
|
136
|
-
Utilities.which("mogrify") or
|
137
|
-
raise MiniMagick::Error, "ImageMagick is not installed or CLI is not found"
|
138
|
-
when :graphicsmagick
|
139
|
-
Utilities.which("gm") or
|
140
|
-
raise MiniMagick::Error, "GraphicsMagick is not installed or CLI is not found"
|
141
|
-
else
|
132
|
+
if not [:imagemagick, :graphicsmagick].include?(@cli)
|
142
133
|
raise ArgumentError,
|
143
134
|
"CLI has to be set to either :imagemagick or :graphicsmagick" \
|
144
135
|
", was set to #{@cli.inspect}"
|
145
136
|
end
|
146
|
-
|
147
|
-
reload_tools
|
148
137
|
end
|
149
138
|
|
150
139
|
def cli_path
|
@@ -155,8 +144,9 @@ module MiniMagick
|
|
155
144
|
@logger || MiniMagick::Logger.new($stdout)
|
156
145
|
end
|
157
146
|
|
147
|
+
# Backwards compatibility
|
158
148
|
def reload_tools
|
159
|
-
MiniMagick
|
149
|
+
warn "[MiniMagick] MiniMagick.reload_tools is deprecated because it is no longer necessary"
|
160
150
|
end
|
161
151
|
|
162
152
|
end
|
@@ -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,6 +106,7 @@ 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|
|
109
|
+
next if line.strip.length.zero?
|
106
110
|
level = line[/^\s*/].length / 2 - 1
|
107
111
|
key_stack.pop until key_stack.size <= level
|
108
112
|
|
@@ -119,9 +123,12 @@ module MiniMagick
|
|
119
123
|
end
|
120
124
|
|
121
125
|
def identify
|
126
|
+
path = @path
|
127
|
+
path += "[0]" unless path =~ /\[\d+\]$/
|
128
|
+
|
122
129
|
MiniMagick::Tool::Identify.new do |builder|
|
123
130
|
yield builder if block_given?
|
124
|
-
builder <<
|
131
|
+
builder << path
|
125
132
|
end
|
126
133
|
end
|
127
134
|
|
data/lib/mini_magick/image.rb
CHANGED
@@ -121,7 +121,7 @@ module MiniMagick
|
|
121
121
|
#
|
122
122
|
def self.attribute(name, key = name.to_s)
|
123
123
|
define_method(name) do |*args|
|
124
|
-
if args.any? &&
|
124
|
+
if args.any? && name != :resolution
|
125
125
|
mogrify { |b| b.send(name, *args) }
|
126
126
|
else
|
127
127
|
@info[key, *args]
|
@@ -332,13 +332,11 @@ module MiniMagick
|
|
332
332
|
# @return [self]
|
333
333
|
#
|
334
334
|
def format(format, page = 0)
|
335
|
-
@info.clear
|
336
|
-
|
337
335
|
if @tempfile
|
338
336
|
new_tempfile = MiniMagick::Utilities.tempfile(".#{format}")
|
339
337
|
new_path = new_tempfile.path
|
340
338
|
else
|
341
|
-
new_path = path.sub(
|
339
|
+
new_path = path.sub(/(\.\w+)?$/, ".#{format}")
|
342
340
|
end
|
343
341
|
|
344
342
|
MiniMagick::Tool::Convert.new do |convert|
|
@@ -355,6 +353,7 @@ module MiniMagick
|
|
355
353
|
end
|
356
354
|
|
357
355
|
path.replace new_path
|
356
|
+
@info.clear
|
358
357
|
|
359
358
|
self
|
360
359
|
end
|
@@ -387,16 +386,12 @@ module MiniMagick
|
|
387
386
|
#
|
388
387
|
def method_missing(name, *args)
|
389
388
|
mogrify do |builder|
|
390
|
-
|
391
|
-
builder.send(name, *args)
|
392
|
-
else
|
393
|
-
super
|
394
|
-
end
|
389
|
+
builder.send(name, *args)
|
395
390
|
end
|
396
391
|
end
|
397
392
|
|
398
393
|
def respond_to_missing?(method_name, include_private = false)
|
399
|
-
MiniMagick::Tool::Mogrify.
|
394
|
+
MiniMagick::Tool::Mogrify.option_methods.include?(method_name.to_s)
|
400
395
|
end
|
401
396
|
|
402
397
|
##
|
@@ -496,8 +491,6 @@ module MiniMagick
|
|
496
491
|
end
|
497
492
|
|
498
493
|
def mogrify(page = nil)
|
499
|
-
@info.clear
|
500
|
-
|
501
494
|
MiniMagick::Tool::Mogrify.new do |builder|
|
502
495
|
builder.instance_eval do
|
503
496
|
def format(*args)
|
@@ -509,6 +502,8 @@ module MiniMagick
|
|
509
502
|
builder << (page ? "#{path}[#{page}]" : path)
|
510
503
|
end
|
511
504
|
|
505
|
+
@info.clear
|
506
|
+
|
512
507
|
self
|
513
508
|
end
|
514
509
|
|
data/lib/mini_magick/tool.rb
CHANGED
@@ -15,11 +15,10 @@ module MiniMagick
|
|
15
15
|
#
|
16
16
|
class Tool
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
18
|
+
CREATION_OPERATORS = %w[
|
19
|
+
xc canvas logo rose gradient radial-gradient plasma pattern label caption
|
20
|
+
text
|
21
|
+
]
|
23
22
|
|
24
23
|
##
|
25
24
|
# Aside from classic instantiation, it also accepts a block, and then
|
@@ -173,89 +172,52 @@ module MiniMagick
|
|
173
172
|
end
|
174
173
|
|
175
174
|
##
|
176
|
-
#
|
177
|
-
# for each command-line tool. It uses the `-help` page of a command-line
|
178
|
-
# tool and generates methods from it. It then includes the generated
|
179
|
-
# module into the tool class.
|
175
|
+
# Define creator operator methods
|
180
176
|
#
|
181
|
-
#
|
177
|
+
# mogrify = MiniMagick::Tool.new("mogrify")
|
178
|
+
# mogrify.canvas("khaki")
|
179
|
+
# mogrify.command.join(" ") #=> "mogrify canvas:khaki"
|
182
180
|
#
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
end
|
188
|
-
|
189
|
-
def initialize(tool_name)
|
190
|
-
@tool_name = tool_name
|
191
|
-
reload_methods
|
192
|
-
self.class.instances << self
|
193
|
-
end
|
194
|
-
|
195
|
-
def to_s
|
196
|
-
"OptionMethods(#{@tool_name})"
|
197
|
-
end
|
198
|
-
|
199
|
-
##
|
200
|
-
# Dynamically generates operator methods from the "-help" page.
|
201
|
-
#
|
202
|
-
def reload_methods
|
203
|
-
instance_methods(false).each { |method| undef_method(method) }
|
204
|
-
creation_operator *creation_operators
|
205
|
-
option *cli_options
|
206
|
-
end
|
207
|
-
|
208
|
-
##
|
209
|
-
# Creates method based on command-line option's name.
|
210
|
-
#
|
211
|
-
# mogrify = MiniMagick::Tool.new("mogrify")
|
212
|
-
# mogrify.antialias
|
213
|
-
# mogrify.depth(8)
|
214
|
-
# mogrify.resize("500x500")
|
215
|
-
# mogrify.command.join(" ")
|
216
|
-
# #=> "mogrify -antialias -depth 8 -resize 500x500"
|
217
|
-
#
|
218
|
-
def option(*options)
|
219
|
-
options.each do |option|
|
220
|
-
define_method(option[1..-1].tr('-', '_')) do |*values|
|
221
|
-
self << option
|
222
|
-
self.merge!(values)
|
223
|
-
self
|
224
|
-
end
|
225
|
-
end
|
181
|
+
CREATION_OPERATORS.each do |operator|
|
182
|
+
define_method(operator.gsub('-', '_')) do |value = nil|
|
183
|
+
self << "#{operator}:#{value}"
|
184
|
+
self
|
226
185
|
end
|
186
|
+
end
|
227
187
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
end
|
188
|
+
##
|
189
|
+
# Any undefined method will be transformed into a CLI option
|
190
|
+
#
|
191
|
+
# mogrify = MiniMagick::Tool.new("mogrify")
|
192
|
+
# mogrify.adaptive_blur("...")
|
193
|
+
# mogrify.foo_bar
|
194
|
+
# mogrify.command.join(" ") "mogrify -adaptive-blur ... -foo-bar"
|
195
|
+
#
|
196
|
+
def method_missing(name, *args)
|
197
|
+
option = "-#{name.to_s.tr('_', '-')}"
|
198
|
+
self << option
|
199
|
+
self.merge!(args)
|
200
|
+
self
|
201
|
+
end
|
243
202
|
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
end
|
203
|
+
def respond_to_missing?(method_name, include_private = false)
|
204
|
+
true
|
205
|
+
end
|
248
206
|
|
249
|
-
|
250
|
-
|
207
|
+
def self.option_methods
|
208
|
+
@option_methods ||= (
|
209
|
+
tool = new
|
251
210
|
tool << "-help"
|
252
211
|
help_page = tool.call(false, stderr: false)
|
253
212
|
|
254
213
|
cli_options = help_page.scan(/^\s+-[a-z\-]+/).map(&:strip)
|
255
|
-
|
256
|
-
|
257
|
-
|
214
|
+
if tool.name == "mogrify" && MiniMagick.graphicsmagick?
|
215
|
+
# These options were undocumented before 2015-06-14 (see gm bug 302)
|
216
|
+
cli_options |= %w[-box -convolve -gravity -linewidth -mattecolor -render -shave]
|
217
|
+
end
|
258
218
|
|
219
|
+
cli_options.map { |o| o[1..-1].tr('-','_') }
|
220
|
+
)
|
259
221
|
end
|
260
222
|
|
261
223
|
end
|
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.3.6
|
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-
|
16
|
+
date: 2015-10-12 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: rake
|