Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk5 min

How to Compress Images from the Command Line Without Visible Quality Loss

A practical guide to lossless and visually acceptable image compression from the command line, with commands for OxiPNG, pngquant, MozJPEG, cwebp, and ImageMagick.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can often make an image file smaller without an obvious change, but no quality setting guarantees that result for every image. If the decoded pixels must remain identical, use a lossless optimizer or encoder. If you can accept a small visual change, try lossy or near-lossless encoding and inspect the output at its intended display size. Keep the original and write each candidate to a separate file.

Choose between identical pixels and an indistinguishable appearance

These are different goals. Lossless compression changes how image data is represented, not the decoded image data. Lossy compression discards image information to reduce file size. A lossy result may look indistinguishable from the source in a particular use, but that is a visual judgment—not a universal guarantee attached to a quality number. Near-lossless processing also changes pixel values, even when the intended visual impact is minimal. See the official documentation for OxiPNG, pngquant and cwebp.

As an Amazon Associate I earn from qualifying purchases.

  • Choose lossless processing when exact decoded pixels matter, such as for archival copies or further editing.
  • Consider lossy or near-lossless processing when smaller files matter more than exact pixel identity and you can review the result.
  • Compare files in the format and at the size your audience will actually see. File size alone does not establish whether quality is acceptable.

Optimize PNG without changing its rendered pixels

OxiPNG is a lossless PNG and APNG optimizer. It tries alternative encodings to reduce file size without changing the decoded image. Savings depend on the input; an already optimized PNG may shrink little or not at all.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
oxipng -o 4 --strip safe output.png input.png

This writes an optimized file to output.png and asks OxiPNG to strip metadata in its “safe” category. Check whether metadata, such as information your workflow depends on, should be retained before using a stripping option. OxiPNG also offers --strip all, which removes a broader set of metadata.

#1 Best Overall
PhotoPad Photo Editing and Image Editor Free [PC Download]
  • Edit and Share digital photos and other images
  • Improve photo quality, adjust the color balance, crop, rotate, resize, and more
  • Add text, frames, clipart, and more to your photos
  • Fun filters such as, sepia, oil paint, cartoon and more.
  • Use touch-up tools to remove red-eye and blemishes

OxiPNG’s --alpha option changes color values in fully transparent pixels. Those changes may not be visible in ordinary display, but the option is technically lossy; omit it when strict pixel preservation matters. ImageMagick’s -quality setting for PNG affects compression parameters, not rendered appearance, because PNG compression remains lossless. Consult the ImageMagick options reference for the installed version’s syntax.

Reduce PNG size further with palette quantization

pngquant uses lossy palette reduction: it can produce a smaller PNG by mapping colors to a reduced palette. The tool’s quality threshold is not a guarantee that an image will look acceptable to you.

Rank #2
GIMP Photo Editor 2026 on CD Disc | Premium Professional Image Editing Software Compatible with Windows 11 10 8.1 8 7 Vista XP PC 32 & 64-Bit & Mac| Lifetime Licence & No Monthly Subscription
  • GIMP – The #1 alternative and fully compatible with Adobe Photoshop and Adobe Photoshop Elements files, it is the ultimate fully featured digital image and photo editing software. Restore old photos, change the background, enhance and manipulate images, or simply create your masterpiece from scratch. Multilingual - English, Spanish (Español) and more languages supported.
  • Full Tool Suite - Graphic designers, photographers, illustrators, artists and beginners can utilize many tools including channels, layers, filters, effects and more. A plethora of file formats are supported including .psd, .jpg, .gif, .png, .pdf, .hdr, .tif, .bmp and many more.
  • Full program that never expires - Free for-life updates and a lifetime license. No yearly subscription or key code is required ever again!
  • Multi-Platform Edition DVD-ROM Disc – Compatible with Microsoft Windows PC and Mac.
  • PixelClassics Bonus Content – Access to 2.7 MILLION royalty-free stock images photo repository, Installation Menu (PC only), Quick Start Guides and comprehensive User Manual PDF.
pngquant --quality=65-80 --output output.png -- input.png

The range tells pngquant the minimum and maximum quality values to target according to its own scale. If it cannot meet the minimum, it can decline to save an output. Review the result closely around gradients, small text, and transparency edges, where palette changes can be especially noticeable.

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

Re-encode JPEG with MozJPEG

MozJPEG’s cjpeg accepts quality values from 0 to 100. Lower settings generally trade image quality for smaller files; re-encoding JPEG at a lower quality is lossy. The MozJPEG manual recommends choosing the lowest setting that decompresses to something visually indistinguishable from the source and notes that the best setting varies by image.

cjpeg -quality 85 -optimize -progressive -outfile output.jpg input.ppm

This example uses a PPM input because accepted input formats depend on the cjpeg build and its documented default support. Check the installed tool’s help before substituting another input format. The value 85 is only an example, not a universally safe setting. MozJPEG’s -optimize usually makes a JPEG somewhat smaller without changing image quality; progressive output implies optimization.

Choose a WebP mode that matches your goal

Google’s cwebp reference describes three useful approaches: lossless encoding, near-lossless preprocessing, and ordinary lossy encoding. Pick the mode deliberately rather than assuming a single -q value has the same meaning in each mode.

Rank #4
Sale
XPPen Mini Keydial ACK05 Wireless Shortcut Keyboard Bluetooth Programmable Express Remote Control with Dial & Customized Express Keys for Drawing Tablet PC MacBook Windows Images Video Editing
  • Wireless Connection: ACK05 wireless shortcut keyboard supports bluetooth 5.0 connection directly, which is Good Design Award 2023 Winners, providing you a more flexible and clean workspace. You can also connect it via a Bluetooth dongle or USB cable. Total three ways connection bring you stable and fast transmission, also can meet your different work scenarios
  • Please Note: If you do not download the driver, it can only be used as a regular shortcut keyboard. However, if you wish to customize the keys or program it, you must download the driver and configure it accordingly. If your device is an iPad or runs on iOS, after receiving the product, you need to download the "Shortcut Remote" app on your device in order to properly set up and use this product properly
  • Compact Size with Large 1000 mAh Battery: The Wireless Shortcut Remote features a thin profile and weighs only 75 g, easy for one hand to hold. With built-in 1000 mAh battery ensures the continuous working for about 300 hours. Ready to speed up your creation whenever you grab it
  • Customize up to forty Shortcuts: The Wireless Shortcut Remote has ten keys. You are allowed to customize four sets through the driver -- up to forty shortcuts. To switch between the sets, you only need to press a single key. Its capability to work with different applications makes itself a powerful productivity tool not only for creation, but also for study, work, and gaming
  • Anti-Ghosting Performance: The Mini Keydial features a new technology of Anti-ghosting for all ten keys, you can control with multi-keys at the same time, which will give you more customizable possibilities

Lossless WebP

cwebp -lossless input.png -o output.webp

This selects lossless encoding. In lossless mode, -q controls encoding effort and file size rather than image quality. By default, WebP may not preserve the color values of fully transparent pixels; use -exact when those hidden values must be preserved.

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

Lossy WebP

cwebp -q 80 input.png -o output.webp

In ordinary lossy mode, a lower -q value produces a smaller, lower-quality file. Treat 80 as a starting point for comparison, not a promise of invisible change. Generate candidates at several settings if file size matters, then inspect them.

Near-lossless WebP

cwebp -near_lossless 60 input.png -o output.webp

Near-lossless preprocessing adjusts pixel values to improve compressibility. Google describes its visual impact as minimal, but it is not pixel-identical. The value 60 is illustrative; assess the output for your image and use.

Google’s WebP overview, last updated in 2025, states that lossless WebP images are 26% smaller than PNGs and that lossy WebP images are 25–34% smaller than comparable JPEG images at equivalent SSIM quality. These are broad format comparisons from Google, not predictions for an individual conversion. The same overview lists native WebP support in Chrome, Safari, Firefox, Edge, and Opera; check compatibility in the actual destination if it is outside those browsers. See Google’s WebP overview.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check the output instead of trusting the setting

Use both a visual review and, when helpful, a difference metric. ImageMagick’s compare can create a difference image and report a mathematical measure; the metric helps diagnose changes but cannot decide whether they matter in context.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
magick compare input.png output.png difference.png

Confirm the syntax for your installed ImageMagick version in the compare reference. Open the difference image to locate changed areas, then inspect the candidate at its intended display size. A metric by itself is not a substitute for checking perceived quality.

  • Check fine detail, small text, gradients, and edges around transparent areas.
  • For transparency workflows, consider both visible edges and whether hidden RGB values must remain unchanged.
  • Check whether metadata or color profiles need to survive the conversion.
  • Compare file sizes and encoding time across representative images, not just one convenient sample.
  • Confirm the output format works in the software, browser, or publishing system that will consume it.

A practical command-line workflow

  1. Keep an untouched source. Direct every command to a new output path so you can recover the original or compare versions.
  2. Set the preservation requirement. If decoded pixels must be identical, start with OxiPNG for PNG or a lossless WebP mode when WebP is suitable. If approximate visual equivalence is acceptable, test pngquant, lossy JPEG, or lossy/near-lossless WebP.
  3. Check format-specific needs. Decide whether transparency, hidden color values, metadata, and color profiles matter, and choose flags accordingly.
  4. Make candidates on representative files. Test images with the details and transparency found in the full batch. Try multiple settings for lossy options rather than treating one quality number as universal.
  5. Review and compare. Inspect visual differences at intended display size and compare the resulting file sizes. Use a metric as a diagnostic, not as the sole acceptance test.
  6. Verify the local tool behavior. Packaging, accepted input formats, and flags can vary by installed version; consult each tool’s --help output before applying a command to a large batch.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.