Search code examples
imagemagickbatch-processing

Run ImageMagick TextCleaner on batch files


It is possible to use the TextCleaner script provided by Fred Weinhaus on batch files ?

I didn't find anything about this. I searched and for other scripts there are various methods but not for TextCleaner. There is a "universal" command to run ?

I use Cygwin on Windows to execute the script.

I am also new to ImageMagick so I don't know too much..

This is the command I use:

textcleaner -g -e normalize -f 50 -o 10 -s 10 image_0in.png image_out.png

Solution

  • My textcleaner script will only process one image at a time. You will have to write a script loop over each image you want to process and then call textcleaner for each image in the loop.

    You can create a list manually of all images you want to process. Or if all your images are in one directory (and they have no spaces in the names), then you can do

    cd to directory holding the images
    list=`ls`
    for img in $list; do
    name=`convert $img -format "%t" info:`
    textcleaner -g -e normalize -f 50 -o 10 -s 10 $img ${name}_out.png
    done
    


    or better (even if files have spaces in the names)

    cd to directory holding the images
    for img in *.png; do
    name=`convert "$img" -format "%t" info:`
    textcleaner -g -e normalize -f 50 -o 10 -s 10 "$img" "${name}_out.png"
    done