Smart image compression for web usage. Automatically reduces file size to under 500KB while preserving visual quality.
FeatureDescriptionSmart CompressionProgressive quality reduction until target size is metAuto ResizeIf quality reduction alone is insufficient, proportionally resizes the imageMulti-Format InputJPEG, PNG, WebP, BMP, TIFF, GIFWebP PreferredAuto WebP output (best compression for web)JPEG FallbackJPEG output option for maximum compatibilityBatch ProcessingCompress all images in a directory at onceRecursive ScanSearch subdirectories recursivelySize TargetConfigurable max file size (default: 500KB)
bash
# 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
bash
# 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
bash
python scripts/web_image_optimizer.py info photo.jpg
The optimizer uses a multi-step approach:
FormatCompressionQualityBrowser SupportRecommendationWebPBestExcellent96%+Default choiceJPEGGoodGood100%Maximum compatibilityPNGLimitedLossless100%Transparency needed
text
hero-banner.png
2682.6 KB --> 41.0 KB (+98.5%)
Format: WEBP Quality: 85 Size: 1280x714
Output: ./hero-banner_web.webp
Install Pillow if needed:
bash
pip3 install Pillow
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)
CodeMeaning0Success1Error (file not found, unsupported format, etc.)
出品: AISoBrand|爱索品牌 — AI搜索优化工具
免费检测你的品牌在AI搜索中有没有存在感 → 30秒出结果