Works with the AI Agents you already use
Image Read Gate — Stop Oversized Screenshots in Context
A PreToolUse hook for the Read tool that checks image headers before Claude Code reads a screenshot. Oversized images are blocked, a smaller JPEG copy is written, and Claude is told to read the copy instead.
$12
Image Read Gate — Stop Oversized Screenshots in Context
Example session with this skill installed
Scan the docs folder and tell me which screenshots the image gate would block before I let you read them, and check docs/retina-dashboard.png on its own.
- Read your context and instructions
- Compiled the image read gate
- Generated the image
Summary
2 of the 3 images in docs/ are over the limits (longest side 1280 px, size 500 KB) and would be blocked. Reading all three would add about 8.7 MB to the session.
Result
$ python3 scripts/image_read_gate.py --scan docs
4.3 MB 2880x1800 retina-dashboard.png
2.3 MB 2560x1440 checkout-flow.png
2 of 3 images exceed the limits (max side 1280 px, max 500.0 KB); reading them all would add about 8.7 MB to a session
$ python3 scripts/image_read_gate.py --check docs/retina-dashboard.png
BLOCK 2880x1800 4.3 MB: longest side 2880 px > 1280; file 4.3 MB > 500.0 KB
$ python3 scripts/image_read_gate.py --check docs/settings-panel.png
ALLOW 1024x640 4.7 KB
| Image | Size | Verdict |
|---|---|---|
| retina-dashboard.png | 2880x1800, 4.3 MB | BLOCK |
| checkout-flow.png | 2560x1440, 2.3 MB | BLOCK |
| settings-panel.png | 1024x640, 4.7 KB | ALLOW |
When a real Read is blocked, Claude is told the path of a smaller JPEG copy (for example 1280x800, 240.3 KB) and reads that instead. The original file is never touched.
Next steps
- Add the hook to
.claude/settings.jsonusingexamples/settings.jsonas the template. - Use
allow_pathsin.claude/image-read-gate.jsonfor images that must stay full size. - Start in warn-only mode if you want to see what it would block first.
Note: the sample images were generated for the README; the gate judges size, not content, and the smaller copy is a JPEG.
retina-dashboard.png
PNG · 1536×1024
Example file from a real run - the skill writes it into your workspace.
Connects securely to your tools. The creator never sees your data.
About this skill
When Claude Code reads an image, the file goes into the conversation as base64 and is re-read on every later turn. One 4 MB Retina screenshot becomes about 5.7 MB of context carried through the rest of the session. Ten of them and the session is slow, expensive and near its limit, for pixels the model scales down anyway.
Image Read Gate is a single-file PreToolUse hook that stops it before the Read happens:
$ python3 scripts/image_read_gate.py --check docs/retina-dashboard.png
BLOCK 2880x1800 4.3 MB: longest side 2880 px > 1280; file 4.3 MB > 500.0 KB
$ python3 scripts/image_read_gate.py --scan docs
4.3 MB 2880x1800 retina-dashboard.png
2.3 MB 2560x1440 checkout-flow.png
2 of 3 images exceed the limits (max side 1280 px, max 500.0 KB); reading them all would add about 8.7 MB to a session
(Sample images generated for the README.)
What it does
- Reads the PNG, JPEG, GIF and WebP headers itself, so the check needs no image library and is instant
- Blocks a Read when the longest side or the file size is over your limit (defaults: 1280 px, 500 KB)
- Writes a smaller JPEG copy with Pillow,
sips(macOS) or ImageMagick, and tells Claude the copy's path: "Read this smaller copy instead" - Never blocks the copy itself, reuses a copy it already made, and never touches your original file
- Optional JSON config: limits, warn-only mode, allowed paths for images that must stay full size, cache folder, a decision log that stores file names only
--scan DIRshows which images in a project would be blocked and what they would add to a session;--check FILEand--resize FILEfor one image
Honest limits, stated in the README: it judges size, not content; the copy is a JPEG, so fine text can get harder to read (raise the limit or allow the path); only the Read tool is covered.
What is inside
SKILL.md,README.md,LICENSEscripts/image_read_gate.pytests/test_gate.py(20 tests)examples/settings.jsonandexamples/image-read-gate.json
Requirements and safety
Python 3.8+, macOS or Linux. The check uses the standard library only; making the smaller copy needs Pillow, sips or ImageMagick. The hook makes no network calls and needs no credentials.
License
Personal, non-transferable license for your own projects, including commercial work. No resale or redistribution.
Only covers the Read tool. JPEG conversion may impact fine text clarity. Requires local installation of Pillow, sips, or ImageMagick.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 5 days ago
Requires