mini_magick 2.0.2 → 2.1
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.
- data/VERSION +1 -1
- data/lib/mini_magick.rb +20 -20
- data/test/image_test.rb +22 -21
- metadata +3 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.1
|
data/lib/mini_magick.rb
CHANGED
@@ -141,21 +141,15 @@ module MiniMagick
|
|
141
141
|
# If an unknown method is called then it is sent through the morgrify program
|
142
142
|
# Look here to find all the commands (http://www.imagemagick.org/script/mogrify.php)
|
143
143
|
def method_missing(symbol, *args)
|
144
|
-
|
145
|
-
|
146
|
-
if MOGRIFY_COMMANDS.include?(guessed_command_name)
|
147
|
-
args.push(@path) # push the path onto the end
|
148
|
-
run_command("mogrify", "-#{guessed_command_name}", *args)
|
149
|
-
self
|
150
|
-
else
|
151
|
-
super(symbol, *args)
|
144
|
+
combine_options do |c|
|
145
|
+
c.method_missing(symbol, *args)
|
152
146
|
end
|
153
147
|
end
|
154
148
|
|
155
149
|
# You can use multiple commands together using this method
|
156
150
|
def combine_options(&block)
|
157
151
|
c = CommandBuilder.new('mogrify')
|
158
|
-
block.call
|
152
|
+
block.call(c)
|
159
153
|
c << @path
|
160
154
|
run(c)
|
161
155
|
end
|
@@ -185,7 +179,7 @@ module MiniMagick
|
|
185
179
|
|
186
180
|
# Outputs a carriage-return delimited format string for Unix and Windows
|
187
181
|
def format_option(format)
|
188
|
-
windows? ? "#{format}\\n" : "#{format}\\\\n"
|
182
|
+
windows? ? "\"#{format}\\n\"" : "\"#{format}\\\\n\""
|
189
183
|
end
|
190
184
|
|
191
185
|
def run_command(command, *args)
|
@@ -207,7 +201,7 @@ module MiniMagick
|
|
207
201
|
else
|
208
202
|
# TODO: should we do something different if the command times out ...?
|
209
203
|
# its definitely better for logging.. otherwise we dont really know
|
210
|
-
raise Error, "Command (#{command.inspect}) failed: #{{:status_code => sub.exitstatus, :output => sub.output}.inspect}"
|
204
|
+
raise Error, "Command (#{command.inspect.gsub("\\", "")}) failed: #{{:status_code => sub.exitstatus, :output => sub.output}.inspect}"
|
211
205
|
end
|
212
206
|
else
|
213
207
|
sub.output
|
@@ -239,27 +233,33 @@ module MiniMagick
|
|
239
233
|
def initialize(command, *options)
|
240
234
|
@command = command
|
241
235
|
@args = []
|
242
|
-
|
243
|
-
options.each { |val| push(val) }
|
236
|
+
options.each { |arg| push(arg) }
|
244
237
|
end
|
245
238
|
|
246
239
|
def command
|
247
240
|
"#{MiniMagick.processor} #{@command} #{@args.join(' ')}".strip
|
248
241
|
end
|
249
242
|
|
250
|
-
def method_missing(symbol, *
|
243
|
+
def method_missing(symbol, *options)
|
251
244
|
guessed_command_name = symbol.to_s.gsub('_','-')
|
252
|
-
if
|
253
|
-
|
254
|
-
|
245
|
+
if guessed_command_name == "format"
|
246
|
+
raise Error, "You must call 'format' on the image object directly!"
|
247
|
+
elsif MOGRIFY_COMMANDS.include?(guessed_command_name)
|
248
|
+
add(guessed_command_name, *options)
|
255
249
|
else
|
256
250
|
super(symbol, *args)
|
257
251
|
end
|
258
252
|
end
|
259
253
|
|
260
|
-
def
|
261
|
-
|
262
|
-
|
254
|
+
def add(command, *options)
|
255
|
+
push "-#{command}"
|
256
|
+
if options.any?
|
257
|
+
push "\"#{options.join(" ")}\""
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
def push(arg)
|
262
|
+
@args << arg.strip
|
263
263
|
end
|
264
264
|
alias :<< :push
|
265
265
|
|
data/test/image_test.rb
CHANGED
@@ -77,19 +77,6 @@ class ImageTest < Test::Unit::TestCase
|
|
77
77
|
image.destroy!
|
78
78
|
end
|
79
79
|
|
80
|
-
# def test_animation_pages
|
81
|
-
# image = Image.from_file(ANIMATION_PATH)
|
82
|
-
# image.format "png", 0
|
83
|
-
# assert_equal "png", image[:format].downcase
|
84
|
-
# image.destroy!
|
85
|
-
# end
|
86
|
-
|
87
|
-
# def test_animation_size
|
88
|
-
# image = Image.from_file(ANIMATION_PATH)
|
89
|
-
# assert_equal image[:size], 76631
|
90
|
-
# image.destroy!
|
91
|
-
# end
|
92
|
-
|
93
80
|
def test_gif_with_jpg_format
|
94
81
|
image = Image.new(GIF_WITH_JPG_EXT)
|
95
82
|
assert_equal "gif", image[:format].downcase
|
@@ -120,7 +107,7 @@ class ImageTest < Test::Unit::TestCase
|
|
120
107
|
image = Image.from_file(SIMPLE_IMAGE_PATH)
|
121
108
|
image.combine_options do |c|
|
122
109
|
c.resize "20x30!"
|
123
|
-
c.blur 50
|
110
|
+
c.blur "50"
|
124
111
|
end
|
125
112
|
|
126
113
|
assert_equal 20, image[:width]
|
@@ -198,11 +185,25 @@ class ImageTest < Test::Unit::TestCase
|
|
198
185
|
end
|
199
186
|
assert `diff -s #{result.path} test/composited.jpg`.include?("identical")
|
200
187
|
end
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
188
|
+
|
189
|
+
def test_issue_8
|
190
|
+
image = Image.from_file(SIMPLE_IMAGE_PATH)
|
191
|
+
assert_nothing_raised do
|
192
|
+
image.combine_options do |c|
|
193
|
+
c.sample "50%"
|
194
|
+
c.rotate "-90>"
|
195
|
+
end
|
196
|
+
end
|
197
|
+
image.destroy!
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_throw_format_error
|
201
|
+
image = Image.from_file(SIMPLE_IMAGE_PATH)
|
202
|
+
assert_raise MiniMagick::Error do
|
203
|
+
image.combine_options do |c|
|
204
|
+
c.format "png"
|
205
|
+
end
|
206
|
+
end
|
207
|
+
image.destroy!
|
208
|
+
end
|
208
209
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_magick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
|
10
|
-
version: 2.0.2
|
8
|
+
- 1
|
9
|
+
version: "2.1"
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Corey Johnson
|