I've read through man pngcrush and it seems that there is no way to crush a PNG file and save it over the original. I want to compress several folders worth of PNGs so it would be useful to do it all with one command!
Currently I am doing pngcrush -q -d tmp *.png then manually cut-pasting the files from the tmp directory to the original folder. So I guess using mv might be the best way to go? Any better ideas?
for file in *.png; do ..., I had issues where the final images had been mixed up (some files where replaced with a crushed version of a completely different file). I suspect this was some kind of race condition where the temporary "pngout.png" file was reused before the system finalised copying it back over the original file. To solve this, generate a uniqueoutfileto prevent pngcrush from using the same temporary file for each operation, e.gpngcrush -ow "$file" "${file%.png}-crushed.png"– Nicholas Nov 08 '23 at 22:54