[bin] Fork into background for PDF processing / OCR
This commit is contained in:
parent
94d7de8217
commit
d2398ed5a4
|
@ -9,12 +9,17 @@ FEED=ARGV[1].eql?("-d") ? 'ADF Duplex' : "ADF Front"
|
|||
SCAN_PATH = Pathname.new("~/Documents/Scans").expand_path
|
||||
CURRENT_FILE = Pathname.new(SCAN_PATH.join(PREFIX))
|
||||
COMMANDS = [
|
||||
"scanimage -d 'epjitsu' --format tiff --batch='#{CURRENT_FILE}-%d.tif' --source '#{FEED}' --mode 'Gray' --resolution 300",
|
||||
"img2pdf --output=#{CURRENT_FILE}_input.pdf #{CURRENT_FILE}*tif",
|
||||
"ocrmypdf -l deu #{CURRENT_FILE}_input.pdf #{CURRENT_FILE}.pdf"
|
||||
]
|
||||
|
||||
Dir.chdir(SCAN_PATH) do
|
||||
COMMANDS.each { |c| system(c) or abort("Sorry, #{c.split.first} made a boo boo") }
|
||||
FileUtils.rm(Dir.glob(["#{CURRENT_FILE}*tif", "#{CURRENT_FILE}_input.pdf"]))
|
||||
system "scanimage -d 'epjitsu' --format tiff --batch='#{CURRENT_FILE}-%d.tif' --source '#{FEED}' --mode 'Gray' --resolution 300" or abort("Sorry, could not talk to scanner")
|
||||
|
||||
pdfbuild = fork do
|
||||
Dir.chdir(SCAN_PATH) do
|
||||
COMMANDS.each { |c| system(c) or abort("Sorry, #{c.split.first} made a boo boo") }
|
||||
FileUtils.rm(Dir.glob(["#{CURRENT_FILE}*tif", "#{CURRENT_FILE}_input.pdf"]))
|
||||
end
|
||||
end
|
||||
|
||||
Process.detach(pdfbuild)
|
||||
|
|
Loading…
Reference in New Issue