@@ -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,14 +21,25 @@ 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
- command = [ @imagemagick_path , "-resize" , width . to_s , "-antialias" , "-render" ,
29
- "-quality" , quality . to_s , "-colorspace" , colorspace ,
30
- "-interlace" , "none" , "-density" , density . to_s ,
31
- "#{ Shellwords . shellescape ( pdf . path ) } [#{ index } ]" , path ]
28
+ alpha = options [ :alpha ]
29
+
30
+ command = [ ]
31
+ command << @imagemagick_path
32
+ command << "-resize #{ width } "
33
+ command << "-alpha #{ alpha } " if alpha
34
+ command << "-antialias"
35
+ command << "-render"
36
+ command << "-quality #{ quality } "
37
+ command << "-colorspace #{ colorspace } "
38
+ command << "-interlace none"
39
+ command << "-density #{ density } "
40
+ command << "#{ Shellwords . shellescape ( pdf . path ) } [#{ index } ]"
41
+ command << path
42
+
32
43
command . unshift ( "PATH=#{ File . dirname ( @ghostscript_path ) } :#{ ENV [ 'PATH' ] } " ) if @ghostscript_path && @ghostscript_path != DefaultGhostScriptPath
33
44
34
45
result = `#{ command . join ( ' ' ) } `
0 commit comments