How to modify multiple images in terminal?
I need to invert multiple .png
images from black to white using command line.
I have found that I might use gimp plugin "plug-in-vinvert" but I can not figure out how to use it. I have tried something like
gimp -b '(plug-in-vinvert "INT32" "filename.png" "/resultsFolder/")'
and many other combinations but with no success.
Solution 1:
Why gimp? Try imagemagick
package. It's a great command line image processor.
In your case you can use it like:
convert -negate src.png dst.png
To modify multiple files at once, e.g.
img_path=./path/to/imgs
img_results=./path/to/imgs/results
mkdir -p $img_results
for img in ${img_path}/*;
do
convert -negate $img ${img_results}/${img#./*};
done
The exact method may depend on how you source your paths.
Here's an actual example...
$ for img in ./png-64/*; do echo convert -negate $img results/${img#./*}; done
convert -negate ./png-64/arrow-block.png results/png-64/arrow-block.png
convert -negate ./png-64/arrow-block-rotated.png results/png-64/arrow-block-rotated.png
convert -negate ./png-64/arrow-shrink.png results/png-64/arrow-shrink.png
Solution 2:
To convert a batch of images, the fastest and shortest way I know is to use the following ImageMagick command:
mogrify -negate *.jpg
N.B. Change image format accordingly and make sure you have a copy of the original images.