Skip to main content

Image Compression

@ BruceL0171632026.7.14compress-image

Compress local PNG, JPEG, and WebP images with predictable output while keeping the originals unless replacement is authorized.

FeaturedVisual Design

Basic info

Name
Image Compression
Description
Compress static PNG, JPEG, or WebP files to WebP or lossless PNG. Use when the user asks to compress or optimize an image, reduce image file size, convert an image to WebP or PNG, or says 图片压缩、压缩图片、减小图片体积、转 WebP、转 PNG. Do NOT trigger when the request involves resizing, cropping, retouching, general image editing, animated images, remote URLs, or formats other than PNG, JPEG, and WebP.

Image Compression

Compress local images and verify every reported size saving.

When to use it

Compress one image

I have a local PNG, JPEG, or WebP file and want a smaller WebP copy without touching the source.

Compress a folder

I need the supported images in one local directory compressed together, with optional subdirectory scanning only when I ask for it.

Keep PNG lossless

I need a smaller PNG but cannot accept lossy output. I want the result written separately and verified before it is reported.

Won't take

This is not for resizing, cropping, retouching, animation, remote URLs, or image formats other than PNG, JPEG, and WebP.

What it produces

The source stays in place by default; replacement happens only with explicit permission.

  • Output file: Writes a WebP at quality 80 by default, or a lossless PNG when requested
  • Batch result: Reports every successful and failed file instead of hiding partial failures
  • Size report: Returns absolute paths, before and after byte counts, and the saved percentage
  • Verification: Confirms every reported output exists before declaring success
  • Never: Overwrites an existing destination, downloads an image, or edits visual content

Prerequisites & boundaries

Prerequisites

Provide exactly one readable local file or directory. The runtime needs Node.js 18.17 or newer and npm; the pinned Sharp dependency may be installed into the user cache on first use.

Scenarios it declines

  • Multiple ambiguous paths or a remote URL
  • Animated or corrupt files and unsupported formats
  • Requests that combine compression with cropping, resizing, or retouching

Subtle edges

  • Recursive directory scanning is opt-in
  • A custom output path works for one file, not a directory
  • Replacing across formats deletes the source only after the new file is complete and verified

Let's Build Together

Follow us and join the community for updates

WeChat community

Scan to join WeChat group

WeChat QR Code