← 返回
未分类

cn-web-image-optimizer

Compress images for web usage. Smart quality reduction + resize to fit under 500KB. Supports JPEG, PNG, WebP, BMP, TIFF input. Auto WebP output for best compression.
Compress images for web usage. Smart quality reduction + resize to fit under 500KB. Supports JPEG, PNG, WebP, BMP, TIFF input. Auto WebP output for best compression.
yjkj999999
未分类 community v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 12
下载
💾 0
安装
1
版本
#latest

概述

Web Image Optimizer

Smart image compression for web usage. Automatically reduces file size to under 500KB while preserving visual quality.

Features

FeatureDescription
----------------------
Smart CompressionProgressive quality reduction until target size is met
Auto ResizeIf quality reduction alone is insufficient, proportionally resizes the image
Multi-Format InputJPEG, PNG, WebP, BMP, TIFF, GIF
WebP PreferredAuto WebP output (best compression for web)
JPEG FallbackJPEG output option for maximum compatibility
Batch ProcessingCompress all images in a directory at once
Recursive ScanSearch subdirectories recursively
Size TargetConfigurable max file size (default: 500KB)

Usage

Single Image Compression

# Compress to WebP (auto, under 500KB)
python scripts/web_image_optimizer.py compress photo.jpg

# Compress to JPEG, max 300KB
python scripts/web_image_optimizer.py compress photo.jpg --format jpeg --max-kb 300

# Compress to PNG
python scripts/web_image_optimizer.py compress photo.png --format png

# Custom output path
python scripts/web_image_optimizer.py compress photo.jpg -o /path/to/output.webp

Batch Processing

# Compress all images in a directory
python scripts/web_image_optimizer.py batch ./images/

# Batch with custom format and size limit
python scripts/web_image_optimizer.py batch ./photos/ --format jpeg --max-kb 200

# Recursive subdirectory scan
python scripts/web_image_optimizer.py batch ./content/ --recursive

Image Info

python scripts/web_image_optimizer.py info photo.jpg

Compression Strategy

The optimizer uses a multi-step approach:

  1. Format Conversion: PNG input is converted to WebP (typically 70-90% smaller)
  2. Quality Reduction: Progressive quality adjustment (85 -> 75 -> 65 -> ...)
  3. Smart Resize: If quality alone cannot meet target, proportionally resize the image
  4. Final Fallback: Save at minimum quality if target cannot be met

Output Format Guide

FormatCompressionQualityBrowser SupportRecommendation
---------------------------------------------------------------
WebPBestExcellent96%+Default choice
JPEGGoodGood100%Maximum compatibility
PNGLimitedLossless100%Transparency needed

Example Output

  hero-banner.png
    2682.6 KB  -->     41.0 KB  (+98.5%)
    Format: WEBP  Quality: 85  Size: 1280x714
    Output: ./hero-banner_web.webp

Dependencies

  • Python 3.6+
  • Pillow (PIL) - Standard Python imaging library

Install Pillow if needed:

pip3 install Pillow

Options

OptionShortDefaultDescription
-------------------------------------
--max-kb-m500Maximum output file size in KB
--format-fautoOutput format: auto/webp/jpeg/png
--quality-q85Starting quality (1-100)
--output-oautoOutput file path
--recursive-rfalseScan subdirectories (batch mode)

Security Notes

  • Pure local processing, no network calls
  • No image data leaves your machine
  • Preserves EXIF metadata is NOT done (metadata stripped for smaller size)
  • No file deletion - original files are preserved

Exit Codes

CodeMeaning
---------------
0Success
1Error (file not found, unsupported format, etc.)

出品: AISoBrand|爱索品牌 — AI搜索优化工具

官网: https://aisobrand.com

免费检测你的品牌在AI搜索中有没有存在感 → 30秒出结果

版本历史

共 1 个版本

  • v1.0.0 从ClawHub迁移发布 当前
    2026-06-07 11:11 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

suspicious
查看报告

🔗 相关推荐

design-media

Nano Banana Pro

steipete
使用 Nano Banana Pro (Gemini 3 Pro Image) 生成或编辑图像。支持文生图、图生图及 1K/2K/4K 分辨率,适用于图像创建、修改及编辑请求,使用 --input-image 指定输入图像。
★ 435 📥 117,964
design-media

UI/UX Pro Max

xobi667
提供 UI/UX 设计智能与实现指导,帮助打造精美界面。适用于 UI 设计、UX 流程、信息架构、视觉风格、设计系统/标记、组件规格、文案/微文案、无障碍及前端 UI(HTML/CSS/JS、React、Next.js、Vue、Svelte
★ 228 📥 48,965
ai-agent

self-improving-agent

user_15292d5a
Captures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails
★ 0 📥 255