返回 Skill 列表
extension
分类: 其它无需 API Key

images-compressor

Compress images, reduce file size, and convert between formats (PNG, JPG, WebP). Use when user wants to: (1) compress/shrink images, (2) reduce image file size, (3) convert image format, (4) batch process images, (5) optimize images for web.

person作者: user_ee3aee92hubcommunity

Image Compressor

Overview

Compress images with configurable quality and format conversion. Supports PNG, JPG, and WebP output. Each output image is verified after compression to ensure it opens correctly.

Quick Start

# Compress a single image (default quality 85, keep original format)
python scripts/compress_image.py input.jpg

# Compress with specific quality and convert to WebP
python scripts/compress_image.py input.png -q 70 -f webp -o compressed/

# Batch compress all images in a folder
python scripts/compress_image.py images/ -q 80 -f jpg -o output/

Usage

Arguments

| Argument | Short | Default | Description | |----------|-------|---------|-------------| | input | — | required | Input image file or directory | | --quality | -q | 85 | Compression quality (1-100) | | --format | -f | same as input | Output format: png, jpg, webp | | --output | -o | ./compressed/ | Output directory |

Quality Guidelines

| Quality | Use Case | |---------|----------| | 90-100 | High quality, archival | | 75-89 | Default (85), good balance | | 50-74 | Web use, smaller files | | 1-49 | Thumbnails, previews |

Supported Formats

| Format | Read | Write | Notes | |--------|------|-------|-------| | PNG | ✅ | ✅ | Lossless support | | JPG/JPEG | ✅ | ✅ | Best for photos | | WebP | ✅ | ✅ | Best web format | | BMP | ✅ | ❌ | Convert to other formats | | GIF | ✅ | ❌ | Convert to other formats |

Script Reference

See scripts/compress_image.py for the compression script. It uses Pillow for all image operations. Output files are validated by re-opening after write.