A skill to batch compress and resize attached images and save them to the output destination directory.
Execution procedure
- Collect the image paths attached by the user
- From the user's instructions, extract specifications such as the output format (
jpg/png), long side size, quality, etc. - Run the following command
Basic (keep original extension, long side 1920px):
python .claude/skills/image-compressor/scripts/compress_images.py "画像1" "画像2" "画像3"
Output as JPG:
python .claude/skills/image-compressor/scripts/compress_images.py "画像1" "画像2" --format jpg
Output as PNG, long side 1280px, quality 90:
python .claude/skills/image-compressor/scripts/compress_images.py "画像1" --format png --max-size 1280 --quality 90
- Report the output paths and compression results to the user
Arguments
| Argument | Description | Default |
|---|---|---|
images |
Input image path (variable length, required) | — |
--format |
Output format (jpg / png) |
keep original extension |
--max-size |
Maximum pixel count of the long side | 1920 |
--quality |
JPEG quality (1-100) | 85 |
Settings
Project root .env Set the following environment variables in (optional. If not set, default values are used):
IMAGE_COMPRESS_OUTPUT_PATH=images/compressed
| Variable name | Description |
|---|---|
IMAGE_COMPRESS_OUTPUT_PATH |
Output destination directory (default: images/compressed) |
Output
- File name: use the original file name as is (
photo.jpg→photo.jpg). Only if a file with the same name already exists, append a sequence number such as_1,_2... - Save destination: the project root's
images/compressed/ - When outputting JPEG, RGBA images are composited with a white background and converted to RGB
- If the long side is less than
--max-size, do not resize and only compress
Dependency package check
On first-time errors, install with the following:
pip install pillow python-dotenv