0

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 ?

1

1 Answer 1

1

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}`);
});
Sign up to request clarification or add additional context in comments.

2 Comments

First of all thank u but when i try your second code i get this error : Error: spawn textcleaner ENOENT . where is the problem in spawn or textcleaner ?
hi, seems your pass an invalid file path, change inputName

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.