Optimize images before reading to reduce token cost and avoid API limits. Auto-resizes to optimal dimensions or extracts text via OCR. Usage: /img <files|--dir> [--ocr] [--lang kor]
Optimize images before reading to avoid API limits and reduce token cost.
/img screenshot.png # Resize then read
/img --dir ./screenshots # Process entire directory
/img --ocr screenshot.png # Extract text via OCR
/img --ocr --lang kor image.png # Korean OCR
/img --ocr --lang eng+kor *.png # Multi-language OCR
/img --max-dim 600 large.png # Custom max dimension
| Condition | Mode | Reason |
|---|
--ocr flag | OCR extraction | User explicitly requested |
| Text/code screenshot (contextual) | Suggest OCR | 90% token savings |
| General images, UI designs | Resize | Visual information needed |
| Less than 5 images, small size | Read directly | Optimization unnecessary |
Run the img-optimize CLI tool:
# Resize mode
img-optimize $FILES_OR_DIR_ARGS
# OCR mode
img-optimize --ocr --lang $LANG $FILES_OR_DIR_ARGS
Resize output: /tmp/claude-images/
OCR output: /tmp/claude-ocr/ (individual .txt files + _combined.txt)
/tmp/claude-images/ using the Read tool/tmp/claude-ocr/ using the Read toolDisplay processing summary:
| Limit | Value |
|---|---|
| Max images per request | 100 |
| Max size per image | 5 MB |
| Total request size | 32 MB |
| Resolution limit (20+ images) | 2000x2000 px |
| Token formula | (width x height) / 750 |
The img-optimize script automatically:
~/.local/bin/img-optimize (Python script)Pillow (pip)tesseract-ocr (optional, for OCR mode)$ARGUMENTS