@@ -81,10 +81,6 @@ Process.times.class.class_eval do
81
81
end
82
82
83
83
ImageOptim ::Path . class_eval do
84
- def shellescape
85
- to_s . shellescape
86
- end
87
-
88
84
def digest
89
85
@digest ||= Digest ::SHA256 . file ( to_s ) . hexdigest
90
86
end
@@ -313,22 +309,21 @@ class Analyser
313
309
images = [ flatten_animation ( @path ) , flatten_animation ( other ) ]
314
310
315
311
alpha_presence = images . map do |image |
316
- Cmd . capture ( "identify -format '%A' #{ image . shellescape } " )
312
+ Cmd . capture ( "identify -format '%A' #{ image . to_s . shellescape } " )
317
313
end
318
314
if alpha_presence . uniq . length == 2
319
315
images . map! { |image | underlay_noise ( image ) }
320
316
end
321
317
322
- nrmse_command = %W[
318
+ nrmse = Cmd . capture ( * %W[
323
319
convert
324
320
#{ images [ 0 ] } -auto-orient
325
321
#{ images [ 1 ] } -auto-orient
326
322
-metric RMSE
327
323
-compare
328
324
-format %[distortion]
329
325
info:
330
- ] . shelljoin
331
- nrmse = Cmd . capture ( nrmse_command ) . to_f
326
+ ] ) . to_f
332
327
unless $CHILD_STATUS. success?
333
328
fail "failed comparison of #{ @path } with #{ other } "
334
329
end
@@ -342,14 +337,11 @@ class Analyser
342
337
flattened = image . temp_path
343
338
Cmd . run ( *%W[
344
339
convert
345
- #{ image . shellescape }
340
+ #{ image }
346
341
-coalesce
347
342
-append
348
- #{ flattened . shellescape }
349
- ] )
350
- unless $CHILD_STATUS. success?
351
- fail "failed flattening of #{ image } "
352
- end
343
+ #{ flattened }
344
+ ] ) || fail ( "failed flattening of #{ image } " )
353
345
flattened
354
346
else
355
347
image
@@ -362,16 +354,13 @@ class Analyser
362
354
with_noise = image . temp_path
363
355
Cmd . run ( *%W[
364
356
convert
365
- #{ image . shellescape }
357
+ #{ image }
366
358
+noise Random
367
- #{ image . shellescape }
359
+ #{ image }
368
360
-flatten
369
361
-alpha off
370
- #{ with_noise . shellescape }
371
- ] )
372
- unless $CHILD_STATUS. success?
373
- fail "failed underlaying noise to #{ image } "
374
- end
362
+ #{ with_noise }
363
+ ] ) || fail ( "failed underlaying noise to #{ image } " )
375
364
with_noise
376
365
end
377
366
end
0 commit comments