Shrink PNG images lossily with pngquant
compress png heavily linux | reduce png file size by half | run pngquant on uploads folder | shrink large png graphics | pngquant | png | images | compressionWarning, destructive. This command deletes, overwrites or changes data in a way that cannot easily be undone. Check every placeholder carefully and make a backup first.
find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f -iname '*.png' -exec pngquant --quality=65-85 --skip-if-larger --strip --force --ext .png {} +Converts PNGs to 8-bit palette images with transparency and writes the result over the original (--ext .png --force). If the minimum quality is not reached or the new file is larger, the original stays untouched. Usually barely visible for graphics, icons and screenshots, for photos WebP is the better choice.
Note: Lossy and irreversible, make a backup first. Install the pngquant package if needed. Skipped files cause a non-zero exit code, which is not an error.
Also searched as
- compress png heavily linux
- reduce png file size by half
- run pngquant on uploads folder
- shrink large png graphics