Skip to content

tommyguolin/image-shrink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image-shrink

A universal AI coding agent skill that compresses images before vision analysis, saving ~80% token costs with minimal quality loss.

Works with Claude Code, Cursor, Codex (OpenAI), Open Code, and any AI agent that reads instructions from markdown files. More agents coming soon.

Why

Vision models charge by the pixel. A 4000×3000 screenshot and its 800px compressed version extract the same information, but the smaller one costs ~80% fewer tokens. This skill ensures every image is compressed before being sent to the model.

Setup

Just tell your AI agent:

Install this skill globally from https://github.com/tommyguolin/image-shrink

The agent will clone the repo and register the skill. Done.

Workflow

1. Compress all images
       python scripts/image-shrink.py <input> [output_dir] [max_size]

2. Analyze compressed images with vision model

3. If details are unclear → re-compress at larger size (1200)

4. Clean up: rm -rf <output_dir>

Token Savings

Max Size Use Case Token Savings
600 Rough layout, large text ~85%
800 Default — UI screenshots ~80%
1200 Small text, diagrams ~65%

Requirements

  • Python 3.6+
  • Pillow (auto-installed on first run)

License

MIT

About

Compress images before AI vision analysis — save ~80% token costs. Works with Claude Code, Cursor, Codex, and any AI coding agent.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages