Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The right command-line image compressor depends on the format you have and whether you can accept changes to image data. For strict PNG optimization, start with OptiPNG; for smaller palette-based PNGs that may look different, consider pngquant. For JPEG, look at MozJPEG; for WebP or AVIF output, use cwebp or avifenc. ImageMagick is a flexible choice when compression is one step in a broader image-processing workflow.

There is no defensible universal ranking of these tools by speed, size, or quality: results vary with the input, settings, and encoder. The 20 entries below are practical candidates grouped by task, not benchmark winners. Check each project’s current license, maintenance, platform support, and package name before adopting it.

Choose a tool by format and fidelity

First decide whether you want to keep the existing format or convert to another one. Then decide how much image-data change is acceptable. Lossless optimization aims to reduce file size without changing the image’s meaningful content; lossy encoding can discard information and may alter visible detail. “Quality 80” is not a universal setting: scales and effects differ by encoder and format.

Need Good starting point Important distinction
Optimize PNG without intended visual changes OptiPNG, pngcrush, oxipng, zopflipng These are PNG-focused candidates; results depend on the file and options.
Reduce PNG size while accepting possible pixel changes pngquant It uses lossy palette compression and documents alpha-transparency support.
Encode JPEG MozJPEG / cjpeg, jpegoptim Encoding quality and optimization options affect size and output.
Create WebP cwebp Supports lossy, lossless, and near-lossless modes; this is format conversion when the input is not WebP.
Create AVIF avifenc, cavif AVIF output is a format conversion, and lossy settings can change image data.
Optimize GIF or SVG Gifsicle, SVGO Animation behavior or SVG rendering can be affected; inspect the result.
Process several formats or combine transformations ImageMagick It is a general image-processing suite, not only a compression specialist.

20 command-line tools to consider

These recommendations are grouped by job rather than ranked. Several tools appear in project dependency lists or roundups, which establishes that they are candidates—not that they share the same maintenance status, supported formats, or suitability for every workflow.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Nero AI Image Upscaler 365 | Enlarge Images & Sharpen Photos | AI Upscaling to 4K | Fix Blurry & Low-Resolution Pictures | Easy Photo Optimization | 1 PC | Windows 11/10
  • ✔️ AI Upscaling up to 8K: Enlarge small, low-resolution, or old photos with crisp details, clean edges, and fewer artifacts — perfect for prints, social media, blogs, and online galleries.
  • ✔️ Fix blurry or noisy photos: AI restores clarity by enhancing textures, sharpening faces, hair, and fine details while reducing noise and JPEG compression errors.
  • ✔️ Ideal for family photos, scans & mobile images: Improve pictures from smartphones, tablets, digital cameras, scanners, and old archives with professional-quality results.
  • ✔️ Fast & easy 1-click enhancement: Batch-process multiple photos at once and improve image quality instantly — no editing experience required.
  • ✔️ Reliable results & broad file support: Works with JPG, PNG, TIFF and more — stable AI processing even on old, compressed or damaged photos.

PNG optimization and palette compression

  1. OptiPNG — A PNG optimizer that tries transformations and compression strategies intended to reduce file size without losing semantic information. It cannot guarantee that every file will shrink. OptiPNG project.
  2. pngquant — A lossy PNG palette compressor with quality and speed controls. Its documentation says it preserves alpha transparency. The project shows one example reduced from 75,628 bytes to 19,996 bytes, described as 73% smaller; that is a project example, not a general expectation or independent benchmark. pngquant project.
  3. oxipng — A PNG optimization candidate named in current tool roundups and installation instructions. Confirm its current upstream manual, release activity, and options before building it into a production workflow. oxipng repository.
  4. zopflipng — A PNG optimization tool named in a roundup. Consult its current upstream documentation for supported options and behavior before use. Zopfli project.
  5. pngcrush — A PNG utility included among optimizer dependencies in a project README. Verify the current upstream project and usage details before selecting it. pngcrush repository.
  6. advpng — Part of the AdvanceCOMP suite and named as an optimizer dependency in a project README. Check its current documentation and project status for details relevant to your files. AdvanceCOMP repository.

JPEG encoding and optimization

  1. MozJPEG / cjpeg — JPEG encoding with options for quality, progressive output, and entropy optimization. More searching or analysis can trade processing time for output size; choose settings against representative images rather than assuming one setting fits all. MozJPEG repository.
  2. jpegoptim — A JPEG optimization component named in an optimizer pipeline. The available evidence does not establish detailed current options or behavior, so check its upstream documentation before relying on a specific feature. jpegoptim repository.

Modern web image encoders

  1. cwebp — Google’s command-line WebP encoder. It supports lossy, lossless, and near-lossless modes, with documented input limits. Use it when WebP is the intended output, and verify the resulting image and metadata. cwebp documentation.
  2. avifenc — The AVIF encoding utility in libavif. It is a format encoder rather than a universal optimizer; inspect output and compatibility in the environments where the images will be used. libavif repository.
  3. cavif — Named in a roundup as a PNG/JPEG-to-AVIF converter. Confirm current upstream input support, maintenance, and command behavior before choosing it. cavif repository.

GIF, SVG, and multi-format workflows

  1. Gifsicle — A GIF optimization component named in an optimizer pipeline. Test animated files as well as stills; confirm that frames, timing, and transparency remain correct. Gifsicle project.
  2. SVGO — An SVG minifier named in an optimizer pipeline. SVG optimization can change rendering, so compare the output in the browsers and applications that matter to you. SVGO repository.
  3. ImageMagick — A broad image-processing command-line suite with format-specific compression controls. Its documentation distinguishes JPEG quality—which trades visual quality against file size—from PNG quality settings, which control compression and do not change PNG appearance. ImageMagick documentation.
  4. Efficient Compression Tool (ECT) — A file-optimizer candidate named in a roundup. The evidence here does not establish its current status or image-specific scope; check upstream details before including it in a workflow. ECT repository.
  5. ImageOptim command-line tools — A project pipeline that names several optimizer binaries, including OptiPNG, pngquant, jpegoptim, SVGO, Gifsicle, cwebp, and avifenc. A dependency list is not proof that every component is equally maintained or right for every job. ImageOptim project.

Additional specialist and pipeline candidates

  1. AdvanceCOMP — A suite whose advpng utility is used in image-optimization dependency lists. Assess the specific utility and its current documentation rather than treating the suite as a single-format encoder. AdvanceCOMP repository.
  2. ImageOptim-CLI — A command-line pipeline associated with image-optimizer components. Its value is orchestration; the underlying encoders determine format support and compression behavior. Confirm the current project status and dependencies. ImageOptim-CLI repository.
  3. ImageMagick-based scripts — For teams already using ImageMagick, a small script can standardize resizing, format conversion, and output settings. Treat the script as workflow glue, not a separate compression algorithm, and document per-format settings explicitly. ImageMagick documentation.

How to select and validate a tool

1. Keep the original format unless conversion is intentional

PNG, JPEG, GIF, SVG, WebP, and AVIF have different image models and encoding options. Optimizing within a format is not the same as converting to another one. For example, encoding a JPEG or PNG as WebP or AVIF can change the format, and a lossy mode can change image data. Decide where the output will be displayed and whether its consumers support the target format.

2. Set a fidelity requirement

  • For assets that must retain their image data, favor lossless optimization and compare output carefully.
  • For a smaller output where some change is acceptable, use a lossy or near-lossless encoder and inspect fine detail, gradients, text, and transparency.
  • For a palette-based PNG workflow, pngquant is explicitly lossy; do not treat it as a strict lossless optimizer.

3. Test on representative files

Make a small test set that includes the kinds of images in your real workload: photographs, screenshots, transparent graphics, animation, or vector illustrations as applicable. Compare file size, dimensions, appearance, transparency, color, and metadata before processing a full library. Keep the originals so you can recover if a setting or batch conversion has an unwanted effect.

4. Inspect metadata and color handling

EXIF data, ICC profiles, comments, and orientation may be stripped, retained, or transformed depending on the tool chain, format, and configuration. Check the resulting files rather than assuming that a smaller output preserves these properties. This matters especially when images rely on embedded color profiles or orientation metadata.

5. Verify the project before deployment

Because “free and open source” is part of the selection criteria, check the upstream license and current maintenance for each tool you plan to use. Also verify the current binary or package name, operating-system support, and command options in the project’s documentation; those details are not established uniformly for all the candidates listed here.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Why there is no universal “best” setting or winner

A setting such as “quality 80” has meaning only within the relevant encoder and format. ImageMagick documents JPEG quality as a visual-quality/file-size trade-off, while its PNG quality settings control compression rather than PNG appearance. MozJPEG, cwebp, and other encoders have their own controls, so numbers should not be compared as if they shared a common scale. No controlled cross-tool benchmark establishes which candidate is universally fastest or produces the smallest acceptable output. Your source image, target format, settings, metadata requirements, and tolerance for visible changes determine the useful choice.

Best Value
Scrivar PDF Pro - Organize, Edit, Compress, Convert, Merge, eSign, OCR & 30+ tools | Lifetime License
  • EVERY PDF TOOL UNLOCKED - 30+ tools in one app: edit text and images, convert, merge, split, compress, sign, OCR, redact, watermark, batch process, and more. No feature gates, no upsells, nothing held back.
  • PAY ONCE, OWN FOREVER — A one-time purchase, not a subscription. Other apps runs $240/year — Scrivar is yours for life, with free updates included.
  • UNLIMITED eSIGN, BUILT IN — Send contracts and forms for signature and track every step. Recipients sign in their browser with no account or app needed. Replace DocuSign and save hundreds a year.
  • PC, MAC, AND WEB — Install on any Win 10/11 PC or macOS 11+ Mac (Intel or Apple Silicon), or work in your browser at scrivar.com. Same tools, same account, everywhere you work.
  • OCR + FULL OFFICE CONVERSION — Turn scanned documents into searchable, selectable text, and convert PDFs to and from Word, Excel, and PowerPoint with formatting kept intact.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.