@@ -9,7 +9,7 @@ class ImageMagickProcessor
9
9
def initialize ( options = { } )
10
10
@imagemagick_path = options [ :imagemagick_path ] || DefaultImagemagickPath
11
11
@ghostscript_path = options [ :ghostscript_path ] || DefaultGhostScriptPath
12
- @original_path = ENV [ 'PATH' ]
12
+ @original_path = ENV [ 'PATH' ]
13
13
end
14
14
15
15
def count ( path )
@@ -21,16 +21,30 @@ def count(path)
21
21
end
22
22
23
23
def save ( pdf , index , path , options )
24
- width = options . fetch ( :width , Grim ::WIDTH )
25
- density = options . fetch ( :density , Grim ::DENSITY )
26
- quality = options . fetch ( :quality , Grim ::QUALITY )
24
+ width = options . fetch ( :width , Grim ::WIDTH )
25
+ density = options . fetch ( :density , Grim ::DENSITY )
26
+ quality = options . fetch ( :quality , Grim ::QUALITY )
27
27
colorspace = options . fetch ( :colorspace , Grim ::COLORSPACE )
28
- alpha = options . fetch ( :alpha , Grim ::ALPHA )
29
- alpha = alpha == '' ? alpha : "-alpha #{ alpha } "
30
- command = [ @imagemagick_path , "-resize" , width . to_s , alpha , "-antialias" , "-render" ,
31
- "-quality" , quality . to_s , "-colorspace" , colorspace ,
32
- "-interlace" , "none" , "-density" , density . to_s ,
33
- "#{ Shellwords . shellescape ( pdf . path ) } [#{ index } ]" , path ]
28
+ alpha = options [ :alpha ]
29
+
30
+ command = [ ]
31
+ command << @imagemagick_path
32
+ command << "-resize"
33
+ command << width . to_s
34
+ command << "-alpha #{ alpha } " if alpha
35
+ command << "-antialias"
36
+ command << "-render"
37
+ command << "-quality"
38
+ command << quality . to_s
39
+ command << "-colorspace"
40
+ command << colorspace
41
+ command << "-interlace"
42
+ command << "none"
43
+ command << "-density"
44
+ command << density . to_s
45
+ command << "#{ Shellwords . shellescape ( pdf . path ) } [#{ index } ]"
46
+ command << path
47
+
34
48
command . unshift ( "PATH=#{ File . dirname ( @ghostscript_path ) } :#{ ENV [ 'PATH' ] } " ) if @ghostscript_path && @ghostscript_path != DefaultGhostScriptPath
35
49
36
50
result = `#{ command . join ( ' ' ) } `
0 commit comments