October 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 NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

How to Compress Images with One Line of Code

Compress a JPEG with one ImageMagick command, or switch the output extension to WebP. Learn how to choose a quality value and verify the result.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

With ImageMagick installed, compress a JPEG in one command: magick input.jpg -quality 80 output.jpg. The number 80 is a starting point, not a universal optimum: check the output’s appearance and file size, then adjust it for your image and use case.

Compress an image with ImageMagick

ImageMagick’s magick command can convert between image formats and apply image operations. In this example, -quality 80 sets the encoder’s quality value, while the output filename determines the target format. See the ImageMagick Convert documentation and its command-line processing guide.

As an Amazon Associate I earn from qualifying purchases.

  1. Install ImageMagick for your operating system and confirm that the magick command is available in your terminal. The exact installation steps depend on your operating system and ImageMagick release.
  2. Run magick input.jpg -quality 80 output.jpg, replacing the filenames with paths to your image and desired output.
  3. Open the output and compare its visual quality and file size with the original. Change the quality value if the result does not suit your needs.

Use a different output filename while you are testing so the original stays intact. The command assumes your ImageMagick build can read the input format and write the output format.

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

Choose the output format and quality

Keep the image as JPEG

For JPEG output, ImageMagick documents a quality scale from 1 (lowest quality and highest compression) to 100 (best quality and least effective compression). A lower value generally favors a smaller file at the cost of more visible degradation; inspect the actual image rather than treating any number as a guarantee. See ImageMagick’s command-line options.

#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.

Convert to WebP

Change the output filename’s extension to WebP: magick input.jpg -quality 80 output.webp. ImageMagick documents a WebP default quality of 75; a quality of 100 or higher selects lossless mode unless explicitly overridden. The same quality number does not mean the same thing across formats. See ImageMagick’s WebP encoding options.

Google also provides cwebp, a dedicated command-line encoder for WebP. Its documented input types include PNG, JPEG and TIFF. Consult the cwebp documentation for its command syntax and options.

Do not treat PNG quality like JPEG quality

ImageMagick documents PNG’s -quality setting as controlling zlib compression level and filter type, rather than using the JPEG-style visual-quality scale. Do not assume that copying a JPEG quality number to PNG produces a comparable result.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Check the result rather than guessing

  • Compare the output with the original at the size and display conditions that matter to you.
  • Check the output file’s size; the command itself does not promise a particular reduction.
  • If the image looks worse than acceptable, raise the quality value and create another output. If it looks acceptable but the file is still too large, try a lower value and inspect again.
  • For WebP, consider whether you want lossy output or lossless mode; ImageMagick’s documented threshold for lossless mode is quality 100 or higher unless overridden.
  • Check that your local ImageMagick build supports the formats you are reading and writing.

There is no single quality number that guarantees the smallest acceptable file for every image. The official documentation describes controls and format behavior, but does not provide an apples-to-apples benchmark for your particular file.

Troubleshoot common problems

“magick” is not recognized or not found

The shell cannot find the ImageMagick command. Install ImageMagick for your operating system or correct your PATH, then open a terminal where magick is available.

The command reports that it cannot read or write a format

Check the input path, filename extension and format support in your ImageMagick build. If you are converting to WebP, verify that the build can write WebP; changing the output extension alone cannot add a missing encoder.

The output is larger than the input

Compression is not guaranteed to shrink every file. Try a different format or quality value, then compare both size and appearance. Keep the original while testing.

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

The image looks too degraded

For JPEG or lossy WebP output, raise the quality setting and regenerate the file. Quality controls behave differently by format, so check the relevant ImageMagick documentation rather than applying the JPEG interpretation to PNG.

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup:

If your task is actually capturing a webpage rather than compressing an image file, ScreenshotNeo is a website screenshot API. Its one-call request can return a screenshot; see the ScreenshotNeo documentation for options and response details.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo removes cookie banners, popups and chat widgets before the shot; bot checks, blank pages and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.

Sign up for ScreenshotNeo’s free plan.

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.

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

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.