mini_magick 4.7.2 → 4.13.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,10 +15,8 @@ module MiniMagick
15
15
  #
16
16
  class Tool
17
17
 
18
- CREATION_OPERATORS = %w[
19
- xc canvas logo rose gradient radial-gradient plasma pattern label caption
20
- text
21
- ]
18
+ CREATION_OPERATORS = %w[xc canvas logo rose gradient radial-gradient plasma
19
+ pattern text pango]
22
20
 
23
21
  ##
24
22
  # Aside from classic instantiation, it also accepts a block, and then
@@ -46,8 +44,10 @@ module MiniMagick
46
44
  # @private
47
45
  attr_reader :name, :args
48
46
 
49
- # @param whiny [Boolean] Whether to raise errors on exit codes different
50
- # than 0.
47
+ # @param name [String]
48
+ # @param options [Hash]
49
+ # @option options [Boolean] :whiny Whether to raise errors on non-zero
50
+ # exit codes.
51
51
  # @example
52
52
  # MiniMagick::Tool::Identify.new(whiny: false) do |identify|
53
53
  # identify.help # returns exit status 1, which would otherwise throw an error
@@ -86,13 +86,13 @@ module MiniMagick
86
86
  whiny = args.fetch(0, @whiny)
87
87
 
88
88
  options[:whiny] = whiny
89
- options[:stderr] = false if block_given?
89
+ options[:stderr] = MiniMagick.warnings && !block_given?
90
90
 
91
91
  shell = MiniMagick::Shell.new
92
92
  stdout, stderr, status = shell.run(command, options)
93
93
  yield stdout, stderr, status if block_given?
94
94
 
95
- stdout.strip
95
+ stdout.chomp("\n")
96
96
  end
97
97
 
98
98
  ##
@@ -112,7 +112,8 @@ module MiniMagick
112
112
 
113
113
  ##
114
114
  # The executable used for this tool. Respects
115
- # {MiniMagick::Configuration#cli} and {MiniMagick::Configuration#cli_path}.
115
+ # {MiniMagick::Configuration#cli}, {MiniMagick::Configuration#cli_path},
116
+ # and {MiniMagick::Configuration#cli_prefix}.
116
117
  #
117
118
  # @return [Array<String>]
118
119
  #
@@ -121,10 +122,20 @@ module MiniMagick
121
122
  # identify = MiniMagick::Tool::Identify.new
122
123
  # identify.executable #=> ["gm", "identify"]
123
124
  #
125
+ # @example
126
+ # MiniMagick.configure do |config|
127
+ # config.cli = :graphicsmagick
128
+ # config.cli_prefix = ['firejail', '--force']
129
+ # end
130
+ # identify = MiniMagick::Tool::Identify.new
131
+ # identify.executable #=> ["firejail", "--force", "gm", "identify"]
132
+ #
124
133
  def executable
125
134
  exe = [name]
135
+ exe.unshift "magick" if MiniMagick.imagemagick7? && name != "magick"
126
136
  exe.unshift "gm" if MiniMagick.graphicsmagick?
127
137
  exe.unshift File.join(MiniMagick.cli_path, exe.shift) if MiniMagick.cli_path
138
+ Array(MiniMagick.cli_prefix).reverse_each { |p| exe.unshift p } if MiniMagick.cli_prefix
128
139
  exe
129
140
  end
130
141
 
@@ -170,7 +181,7 @@ module MiniMagick
170
181
  # Create an ImageMagick stack in the command (surround.
171
182
  #
172
183
  # @example
173
- # MiniMagick::Tool::Convert.new do |convert|
184
+ # MiniMagick::Tool::Magick.new do |convert|
174
185
  # convert << "wand.gif"
175
186
  # convert.stack do |stack|
176
187
  # stack << "wand.gif"
@@ -181,9 +192,15 @@ module MiniMagick
181
192
  # end
182
193
  # # executes `convert wand.gif \( wizard.gif -rotate 30 \) +append images.gif`
183
194
  #
184
- def stack
195
+ def stack(*args)
185
196
  self << "("
186
- yield self
197
+ args.each do |value|
198
+ case value
199
+ when Hash then value.each { |key, value| send(key, *value) }
200
+ when String then self << value
201
+ end
202
+ end
203
+ yield self if block_given?
187
204
  self << ")"
188
205
  end
189
206
 
@@ -204,7 +221,7 @@ module MiniMagick
204
221
  # Adds ImageMagick's pseudo-filename `-` for standard output.
205
222
  #
206
223
  # @example
207
- # content = MiniMagick::Tool::Convert.new do |convert|
224
+ # content = MiniMagick::Tool::Magick.new do |convert|
208
225
  # convert << "input.jpg"
209
226
  # convert.auto_orient
210
227
  # convert.stdout
@@ -218,12 +235,13 @@ module MiniMagick
218
235
  ##
219
236
  # Define creator operator methods
220
237
  #
238
+ # @example
221
239
  # mogrify = MiniMagick::Tool.new("mogrify")
222
240
  # mogrify.canvas("khaki")
223
241
  # mogrify.command.join(" ") #=> "mogrify canvas:khaki"
224
242
  #
225
243
  CREATION_OPERATORS.each do |operator|
226
- define_method(operator.gsub('-', '_')) do |value = nil|
244
+ define_method(operator.tr('-', '_')) do |value = nil|
227
245
  self << "#{operator}:#{value}"
228
246
  self
229
247
  end
@@ -242,10 +260,11 @@ module MiniMagick
242
260
  ##
243
261
  # Any undefined method will be transformed into a CLI option
244
262
  #
263
+ # @example
245
264
  # mogrify = MiniMagick::Tool.new("mogrify")
246
265
  # mogrify.adaptive_blur("...")
247
266
  # mogrify.foo_bar
248
- # mogrify.command.join(" ") "mogrify -adaptive-blur ... -foo-bar"
267
+ # mogrify.command.join(" ") # => "mogrify -adaptive-blur ... -foo-bar"
249
268
  #
250
269
  def method_missing(name, *args)
251
270
  option = "-#{name.to_s.tr('_', '-')}"
@@ -254,10 +273,6 @@ module MiniMagick
254
273
  self
255
274
  end
256
275
 
257
- def respond_to_missing?(method_name, include_private = false)
258
- true
259
- end
260
-
261
276
  def self.option_methods
262
277
  @option_methods ||= (
263
278
  tool = new(whiny: false)
@@ -285,6 +300,7 @@ require "mini_magick/tool/convert"
285
300
  require "mini_magick/tool/display"
286
301
  require "mini_magick/tool/identify"
287
302
  require "mini_magick/tool/import"
303
+ require "mini_magick/tool/magick"
288
304
  require "mini_magick/tool/mogrify"
289
305
  require "mini_magick/tool/mogrify_restricted"
290
306
  require "mini_magick/tool/montage"
@@ -24,7 +24,7 @@ module MiniMagick
24
24
  end
25
25
 
26
26
  def tempfile(extension)
27
- Tempfile.new(["mini_magick", extension]).tap do |tempfile|
27
+ Tempfile.new(["mini_magick", extension], MiniMagick.tmpdir).tap do |tempfile|
28
28
  tempfile.binmode
29
29
  yield tempfile if block_given?
30
30
  tempfile.close
@@ -8,7 +8,7 @@ module MiniMagick
8
8
 
9
9
  module VERSION
10
10
  MAJOR = 4
11
- MINOR = 7
11
+ MINOR = 13
12
12
  TINY = 2
13
13
  PRE = nil
14
14
 
data/lib/mini_magick.rb CHANGED
@@ -30,6 +30,14 @@ module MiniMagick
30
30
  cli == :imagemagick
31
31
  end
32
32
 
33
+ ##
34
+ # Checks whether the CLI used is ImageMagick 7.
35
+ #
36
+ # @return [Boolean]
37
+ def self.imagemagick7?
38
+ cli == :imagemagick7
39
+ end
40
+
33
41
  ##
34
42
  # Checks whether the CLI used is GraphicsMagick.
35
43
  #
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.7.2
4
+ version: 4.13.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Johnson
@@ -10,10 +10,10 @@ authors:
10
10
  - James Miller
11
11
  - Thiago Fernandes Massa
12
12
  - Janko Marohnić
13
- autorequire:
13
+ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2017-06-20 00:00:00.000000000 Z
16
+ date: 2024-07-08 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rake
@@ -43,48 +43,6 @@ dependencies:
43
43
  - - "~>"
44
44
  - !ruby/object:Gem::Version
45
45
  version: 3.5.0
46
- - !ruby/object:Gem::Dependency
47
- name: guard
48
- requirement: !ruby/object:Gem::Requirement
49
- requirements:
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: '0'
53
- type: :development
54
- prerelease: false
55
- version_requirements: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: '0'
60
- - !ruby/object:Gem::Dependency
61
- name: guard-rspec
62
- requirement: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: '0'
67
- type: :development
68
- prerelease: false
69
- version_requirements: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- version: '0'
74
- - !ruby/object:Gem::Dependency
75
- name: posix-spawn
76
- requirement: !ruby/object:Gem::Requirement
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- version: '0'
81
- type: :development
82
- prerelease: false
83
- version_requirements: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- version: '0'
88
46
  - !ruby/object:Gem::Dependency
89
47
  name: webmock
90
48
  requirement: !ruby/object:Gem::Requirement
@@ -112,6 +70,7 @@ extensions: []
112
70
  extra_rdoc_files: []
113
71
  files:
114
72
  - MIT-LICENSE
73
+ - README.md
115
74
  - Rakefile
116
75
  - lib/mini_gmagick.rb
117
76
  - lib/mini_magick.rb
@@ -128,6 +87,7 @@ files:
128
87
  - lib/mini_magick/tool/display.rb
129
88
  - lib/mini_magick/tool/identify.rb
130
89
  - lib/mini_magick/tool/import.rb
90
+ - lib/mini_magick/tool/magick.rb
131
91
  - lib/mini_magick/tool/mogrify.rb
132
92
  - lib/mini_magick/tool/mogrify_restricted.rb
133
93
  - lib/mini_magick/tool/montage.rb
@@ -138,7 +98,7 @@ homepage: https://github.com/minimagick/minimagick
138
98
  licenses:
139
99
  - MIT
140
100
  metadata: {}
141
- post_install_message:
101
+ post_install_message:
142
102
  rdoc_options: []
143
103
  require_paths:
144
104
  - lib
@@ -146,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
106
  requirements:
147
107
  - - ">="
148
108
  - !ruby/object:Gem::Version
149
- version: '0'
109
+ version: '2.3'
150
110
  required_rubygems_version: !ruby/object:Gem::Requirement
151
111
  requirements:
152
112
  - - ">="
@@ -154,9 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
114
  version: '0'
155
115
  requirements:
156
116
  - You must have ImageMagick or GraphicsMagick installed
157
- rubyforge_project:
158
- rubygems_version: 2.6.11
159
- signing_key:
117
+ rubygems_version: 3.5.11
118
+ signing_key:
160
119
  specification_version: 4
161
120
  summary: Manipulate images with minimal use of memory via ImageMagick / GraphicsMagick
162
121
  test_files: []