kornelski / pngquant

Lossy PNG compressor — pngquant command based on libimagequant library
https://pngquant.org
Other
5.25k stars 487 forks source link

Can you confirm that the input image is never overwritten in case pngquant fails? #345

Closed cesaredamico closed 5 years ago

cesaredamico commented 5 years ago

We'd like to use the original image if pngquant fails, but we're afraid it may get corrupted in case pngquant fails at any moment. Can you confirm that the original image is never overwritten if pngquant fails? Thanks!

zvezdochiot commented 5 years ago

342

kornelski commented 5 years ago

The file is replaced atomically on success, i.e. pngquant writes to a temp file and then renames it.

The exception is when you use shell stdout redirection > file syntax. This is then handled by the shell, not by pngquant.