02 Apr 2021  Snippets


Install pngquant:

sudo apt install pngquant -y

Shell alias for png filename.png command usage with sensible defaults:

png() { pngquant "[email protected]" --quality 90-100 --speed 1 --skip-if-larger --strip --ext -quant.png }

Above command does the following:

  • Uses a quality scale with minimum of 90% and maximum of 100% for best results
  • Prioritizes quality over speed, which makes no difference on modern hardware
  • Skips the operation if the output file will be larger than the input file
  • Strips all metadata from the file
  • Adds a -quant.png suffix to the file

Example command and output with a filesize reduction of ~64%:

png Screenshot-from-2021-04-02-09-55-45.png

# (exit code 0)

-rw-rw-r-- 1 paramdeo paramdeo  91K Apr  2 09:55 'Screenshot from 2021-04-02 09-55-45.png'
-rw-rw-r-- 1 paramdeo paramdeo  33K Apr  2 10:07 'Screenshot from 2021-04-02 09-55-45-quant.png'
Webmentions & Comments

Copyright © Paramdeo Singh. Built with Jekyll and ☕️ in Guyana. All Rights Reserved.

Last Site Build on Thu, 21 Oct 2021 17:49:44 -0400

1MB Club Badge

Paramdeo Singh Guyana

Riding the wave of consciousness in this treacherous mortal sea.

Technology Design Strategy Literature Personal Blogs