↑ ↓ select, Enter open, Esc close

Shrink PNG images lossily with pngquant

Adjust the values, the command updates live
user@server
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

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.