@@ -3,19 +3,19 @@ class ImageMagickProcessor
3
3
4
4
# ghostscript prints out a warning, this regex matches it
5
5
WarningRegex = /\* \* \* \* .*\n /
6
+ DefaultImagemagickPath = 'convert'
7
+ DefaultGhostScriptPath = 'gs'
6
8
7
9
def initialize ( options = { } )
8
- @imagemagick_path = options [ :imagemagick_path ] || 'convert'
9
- @ghostscript_path = options [ :ghostscript_path ]
10
- @ghostscript_exec = options [ :ghostscript_executable ] || 'gs'
10
+ @imagemagick_path = options [ :imagemagick_path ] || DefaultImagemagickPath
11
+ @ghostscript_path = options [ :ghostscript_path ] || DefaultGhostScriptPath
11
12
@original_path = ENV [ 'PATH' ]
12
13
end
13
14
14
15
def count ( path )
15
- command = [ "-dNODISPLAY" , "-q" ,
16
+ command = [ @ghostscript_path , "-dNODISPLAY" , "-q" ,
16
17
"-sFile=#{ Shellwords . shellescape ( path ) } " ,
17
18
File . expand_path ( '../../../lib/pdf_info.ps' , __FILE__ ) ]
18
- @ghostscript_path ? command . unshift ( @ghostscript_path ) : command . unshift ( @ghostscript_exec )
19
19
result = `#{ command . join ( ' ' ) } `
20
20
result . gsub ( WarningRegex , '' ) . to_i
21
21
end
@@ -29,7 +29,7 @@ def save(pdf, index, path, options)
29
29
"-quality" , quality . to_s , "-colorspace" , colorspace ,
30
30
"-interlace" , "none" , "-density" , density . to_s ,
31
31
"#{ Shellwords . shellescape ( pdf . path ) } [#{ index } ]" , path ]
32
- command . unshift ( "PATH=#{ File . dirname ( @ghostscript_path ) } :#{ ENV [ 'PATH' ] } " ) if @ghostscript_path
32
+ command . unshift ( "PATH=#{ File . dirname ( @ghostscript_path ) } :#{ ENV [ 'PATH' ] } " ) if @ghostscript_path && @ghostscript_path != DefaultGhostScriptPath
33
33
34
34
result = `#{ command . join ( ' ' ) } `
35
35
0 commit comments