remove need for temp files for sam2p, speeding up processing
This commit is contained in:
parent
dc5b186c7b
commit
f5fa6f7373
@ -84,6 +84,9 @@ class Filter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def convert(command, verbose = false)
|
def convert(command, verbose = false)
|
||||||
|
if verbose
|
||||||
|
puts "convert " + (verbose ? "-verbose " : "" ) + [ command ].flatten.join(" ")
|
||||||
|
end
|
||||||
system("convert " + (verbose ? "-verbose " : "" ) + [ command ].flatten.join(" "))
|
system("convert " + (verbose ? "-verbose " : "" ) + [ command ].flatten.join(" "))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -76,7 +76,12 @@ module PrintHandling
|
|||||||
end
|
end
|
||||||
|
|
||||||
command << "-draw 'image Over 0,0 0,0 \"#{input}\"'"
|
command << "-draw 'image Over 0,0 0,0 \"#{input}\"'"
|
||||||
command << "\"#{output}\""
|
|
||||||
|
if output[0,1] == "|"
|
||||||
|
command << output[1..-1]
|
||||||
|
else
|
||||||
|
command << "\"#{output}\""
|
||||||
|
end
|
||||||
|
|
||||||
convert(command)
|
convert(command)
|
||||||
end
|
end
|
||||||
@ -166,7 +171,7 @@ class SVGToTempBitmap < InputFilter
|
|||||||
x_offset = (grid_width - image_width) / 2
|
x_offset = (grid_width - image_width) / 2
|
||||||
y_offset = (grid_height - image_height) / 2
|
y_offset = (grid_height - image_height) / 2
|
||||||
|
|
||||||
command << "-draw 'image Over #{x * grid_width + x_offset},#{y * grid_height + y_offset} 0,0 \"#{file}\"'"
|
command << "\"#{file}\" -geometry +#{x * grid_width + x_offset}+#{y * grid_height + y_offset} -composite"
|
||||||
end
|
end
|
||||||
|
|
||||||
command << OutputFilename
|
command << OutputFilename
|
||||||
@ -268,10 +273,7 @@ end
|
|||||||
class TempBitmapToPrint < OutputFilter
|
class TempBitmapToPrint < OutputFilter
|
||||||
include PrintHandling
|
include PrintHandling
|
||||||
def build(input, output)
|
def build(input, output)
|
||||||
build_for_print(input, "tmp2.pbm")
|
build_for_print(input, "| pbm:- | sam2p -c:lzw -m:dpi:#{(72.0 * (72.0 / @config['dpi'].to_f))} - PDF:\"#{output}\"")
|
||||||
|
|
||||||
system("sam2p -c:lzw -m:dpi:#{(72.0 * (72.0 / @config['dpi'].to_f))} tmp2.pbm PDF:\"#{output}\"");
|
|
||||||
system("rm tmp2.pbm")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -293,8 +295,7 @@ class TempBitmapToPaginatedPrint < OutputFilter
|
|||||||
|
|
||||||
commands = [
|
commands = [
|
||||||
"-size #{page_width * 2}x#{page_height}",
|
"-size #{page_width * 2}x#{page_height}",
|
||||||
"xc:white",
|
"xc:white"
|
||||||
"-gravity Northwest"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
left_creep = 0
|
left_creep = 0
|
||||||
@ -307,16 +308,14 @@ class TempBitmapToPaginatedPrint < OutputFilter
|
|||||||
end
|
end
|
||||||
|
|
||||||
if left
|
if left
|
||||||
commands << "-draw 'image Over -#{left_creep.to_i},0 0,0 \"#{left}\"'"
|
commands << "\"#{left}\" -geometry +#{left_creep.to_i}+0 -composite"
|
||||||
end
|
end
|
||||||
if right
|
if right
|
||||||
commands << "-draw 'image Over #{(page_width + right_creep).to_i},0 0,0 \"#{right}\"'"
|
commands << "\"#{right}\" -geometry +#{(page_width + right_creep).to_i}+0 -composite"
|
||||||
end
|
end
|
||||||
commands << "-channel RGB -depth 8 tmp2.png"
|
commands << "-colorspace RGB -depth 8 pnm:- | sam2p -c:lzw -m:dpi:#{(72.0 * (72.0 / @config['dpi'].to_f))} - PDF:\"#{output}\""
|
||||||
|
|
||||||
convert(commands)
|
convert(commands)
|
||||||
system("sam2p -c:lzw -m:dpi:#{(72.0 * (72.0 / @config['dpi'].to_f))} tmp2.png PDF:\"#{output}\"");
|
|
||||||
system("rm tmp2.png")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user