Skip to content

Commit c05ace3

Browse files
committed
Change to capture2e
1 parent c3706d2 commit c05ace3

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib/grim/image_magick_processor.rb

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'open3'
2+
13
module Grim
24
class ImageMagickProcessor
35

@@ -39,16 +41,16 @@ def save(pdf, index, path, options)
3941
command << "-density #{density}"
4042
command << "#{Shellwords.shellescape(pdf.path)}[#{index}]"
4143
command << path
42-
43-
begin
44-
ENV['PATH'] = "#{File.dirname(@ghostscript_path)}#{File::PATH_SEPARATOR}#{ENV['PATH']}" if @ghostscript_path && @ghostscript_path != DefaultGhostScriptPath
45-
result = `#{command.join(' ')}`
46-
ensure
47-
ENV['PATH'] = @original_path if @ghostscript_path && @ghostscript_path != DefaultGhostScriptPath
44+
45+
command_env = {}
46+
47+
if @ghostscript_path && @ghostscript_path != DefaultGhostScriptPath
48+
command_env['PATH'] = "#{File.dirname(@ghostscript_path)}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
4849
end
49-
50-
$? == 0 || raise(UnprocessablePage, result)
51-
50+
51+
result, status = Open3.capture2e(command_env, command.join(' '))
52+
53+
status.success? || raise(UnprocessablePage, result)
5254
end
5355
end
5456
end

0 commit comments

Comments
 (0)