Monday, May 13, 2024
20
rated 0 times [  20] [ 0]  / answers: 1 / hits: 18738  / 3 Years ago, wed, october 13, 2021, 10:47:36

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.


More From » command-line

 Answers
5

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

[#22666] Friday, October 15, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alliulet

Total Points: 46
Total Questions: 109
Total Answers: 97

Location: Svalbard and Jan Mayen
Member since Sat, Oct 10, 2020
4 Years ago
;