pngquant to compress PNG images on the terminal

pngquant to compress PNG images on the terminal


I used to use “ImageOptim” to compress png images. But when I thought about using Terminal on a Mac for a bit, I really wanted to do it on a black screen! I started to think about it. Then I found a tool called pngquant.

Confirmation Environment

How to install it

Open a terminal and enter the following command. It will take quite a while to install, so please be patient. (Homebrew required)

 brew install pngquant

Basic Usage

Go to the directory where the png image is located and type the following command. You will end up with no output and no results. It may be a bit crude, but don’t worry, it works fine.

 pngquant --ext .png --force --speed 1 *.png


Overwrite the output file.


Append characters to the output file name.

 # Nothing added (it will be the same name)
--ext .png

Add -output.png to the end of the file.

--ext -output.png

hogehoge-output.png and fugafuga-output.png Image.

–speed 1

Indicates the speed of compression, from 1 (slow) to 10 (fast). The slower the speed, the higher the compression rate.

Other similar tools