kornelski/pngquant logo

kornelski/pngquant

Free

Lossy PNG compressor — pngquant command based on libimagequant library

FreeFree tier
Type
Open Source

About kornelski/pngquant

pngquant is a lossy PNG compression tool that dramatically reduces file sizes by converting 24/32-bit PNG images to efficient 8-bit PNG format with alpha channel, often achieving 60-80% smaller files. The compressed images remain fully standards-compliant and are supported by all web browsers and operating systems. pngquant features high-quality palette generation using advanced quantization with gamma correction and premultiplied alpha, along with a unique dithering algorithm that avoids adding unnecessary noise. It includes a configurable quality level (similar to JPEG) that automatically determines the required number of colors and can skip images that cannot meet the desired quality. The tool is fast and modern, built on the portable libimagequant library with multicore support via OpenMP and Intel SSE optimizations. This is the official pngquant repository, and the compression engine is also available as an embeddable library.

Key Features

High-quality palette generation with advanced quantization and gamma correction
Unique dithering algorithm that minimizes noise addition
Configurable quality level (0-100) similar to JPEG, with automatic color count selection
Fast performance with multicore (OpenMP) and Intel SSE optimizations
Batch conversion of multiple files and stdin/stdout chaining
Options for quality, speed, dithering level, posterization, and stripping metadata
Standards-compliant output compatible with all browsers and operating systems
Available as both command-line tool and embeddable library (libimagequant)

Pros & Cons

Pros
  • Significant file size reduction (60-80% smaller than standard 24/32-bit PNG)
  • High-quality output with advanced quantization and dithering algorithms
  • Fully standards-compliant and universally supported across browsers and OS
  • Fast processing with multicore and SSE optimizations
  • Open source and free to use with no restrictions
  • Configurable quality levels to balance size and visual fidelity
Cons
  • Lossy compression introduces some data loss and may not suit all use cases
  • Command-line interface only, no graphical user interface included
  • Limited to 8-bit color palette (256 colors max per image)
  • Not ideal for images requiring full 24-bit color depth or lossless preservation

Best For

Optimizing PNG images for web performance to reduce page load timesBatch compression of image assets in development workflowsPreprocessing images for mobile apps or games where file size is criticalIntegrating PNG compression into build pipelines or automated scriptsReducing storage space for PNG image collections

FAQ

What is pngquant?
pngquant is a lossy PNG compressor that converts 24/32-bit PNG images to more efficient 8-bit PNG format with alpha channel, typically reducing file size by 60-80% while maintaining visual quality.
Is pngquant free to use?
Yes, pngquant is open source and free to use. The project is hosted on GitHub and is licensed under an open source license.
What platforms does pngquant support?
pngquant is written in C99 and is portable across Unix-like systems, Windows, and macOS. It uses OpenMP for multicore support.
How does the quality option work?
The --quality option accepts a min-max range (0-100). pngquant uses the least colors needed to meet or exceed the max quality. If the result falls below the min quality, the image is not saved and pngquant exits with status code 99.
Can pngquant be used in scripts or pipelines?
Yes, pngquant supports stdin/stdout chaining and batch conversion of multiple files, making it suitable for integration into automated workflows and build scripts.