explaingit

kornelski/pngquant

5,632CAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

pngquant is a command-line tool that shrinks PNG image files by 60-80% by reducing them to 256 colors, while keeping full transparency support, compatible with every modern browser and OS, with a quality setting similar to JPEG compression.

Mindmap

mindmap
  root((pngquant))
    What it does
      Compress PNG files
      60-80% size reduction
      Preserve transparency
    How it works
      Reduces to 256 colors
      Quality range setting
      Lossy compression
    Usage
      Single file
      Batch with wildcard
      Pipe in workflows
    Tech Stack
      C language
      libimagequant library
      Multi-core support
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Compress PNG images for a website to cut page load time by 60-80% while keeping full transparency support.

USE CASE 2

Batch-compress hundreds of PNG screenshots or icons in one command using a wildcard file pattern.

USE CASE 3

Embed pngquant's compression engine (libimagequant) in your own image processing tool to shrink PNGs programmatically.

USE CASE 4

Use pngquant in a build pipeline to automatically compress all PNG assets before deploying a web project.

Tech stack

Clibimagequant

Getting it running

Difficulty · easy Time to first run · 5min

Commercial or App Store use requires a separate paid license, GPL v3 does not cover closed-source distribution.

Licensed under GPL v3 for open source use, a separate commercial license is required for closed-source or App Store applications.

In plain English

pngquant is a command-line tool that makes PNG image files significantly smaller. It does this by converting full-color PNG images (which can store millions of colors) into a version that uses at most 256 colors, a format called indexed or 8-bit PNG. The resulting files are typically 60 to 80 percent smaller than the originals and still support transparency. Every modern browser and operating system can display them, because 8-bit PNG is a standard format. The compression is lossy, meaning some color information is discarded, but the tool uses a quality setting similar to JPEG compression so you can control how much quality you are willing to give up. You set a minimum and maximum quality range (on a scale of 0 to 100), and the tool picks the smallest file that still meets your target. If it cannot reach your minimum quality threshold, it skips the file rather than saving a poor result. Using it is straightforward. You can compress a single file, run it on a batch of files at once using a wildcard, or pipe images through it as part of a larger processing workflow. Options include controlling the compression speed, disabling or adjusting dithering (a technique that adds subtle pixel patterns to smooth color transitions), stripping metadata from the file, and setting a custom output filename or extension. The compression engine is built on a library called libimagequant, which is also available separately for developers who want to embed the same compression logic in their own software. The tool takes advantage of multiple CPU cores and certain hardware instructions where available to run faster. pngquant is licensed under GPL v3 for open source use and under a separate commercial license for closed-source or App Store applications.

Copy-paste prompts

Prompt 1
I have a folder of PNG screenshots and want to compress them all by at least 70% without visible quality loss. Show me the pngquant command to batch-process the whole folder.
Prompt 2
How do I use pngquant to compress a PNG to the smallest file size while keeping quality above 80? Show me the exact flags.
Prompt 3
I'm building a Python image processing script and want to run pngquant as a subprocess. Show me how to call it and detect when it skipped a file due to quality constraints.
Prompt 4
How do I pipe images through pngquant in a shell pipeline, reading from stdin and writing to stdout?
Open on GitHub → Explain another repo

← kornelski on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.