Asma_Kh
Asma_Kh

Reputation: 93

Run imageMagick command with Nodejs

I am trying to improve the quality of a scanned PDF to proceed to OCR. I found the command textcleaner that uses ImageMagick. So how can I include this :

textcleaner -g -e normalize -f 30 -o 12 -s 2 original.jpg output.jpg

in my Nodejs code ?

Upvotes: 0

Views: 1470

Answers (1)

Constantin Guidon
Constantin Guidon

Reputation: 1892

you can use exec:

exec(`textcleaner -g -e normalize -f 30 -o 12 -s 2 ${inputName} ${outputName}`);

or use a child process

const { spawn } = require('child_process');
const textcleaner = spawn('textcleaner', ['-g', '-e', 'normalize', '-f 30', '-o 12', '-s 2', inputName, outputName]);

textcleaner.stdout.on('data', (data) => {
  console.log(`stdout: ${data}`);
});

Upvotes: 1

Related Questions