To compress images with Claude Code, connect an MCP server that does the encoding and let the agent call it with explicit settings. Smol is one: it runs on your Mac, takes absolute file paths, and returns per-file results the agent can check. Below are the limits you are working around and the setting for each.
| What the agent handles | The limit you hit | The Smol setting |
|---|---|---|
| Screenshots and photos you attach to a prompt | 10 MB per image on the Claude API, counted base64-encoded; long edge 1568 px on the standard tier | Compress, JPG or original format, quality 80, maximum dimension 1568 |
| Hero and product images in a web repo | GitHub warns above 50 MiB and blocks above 100 MiB; the repo itself should stay small | Compress, WebP or AVIF, quality 75 (65 for AVIF), maximum dimension to your layout |
| A folder of 100 or more images in one task | Anthropic: stricter 2000 px per-side rule above 20 images in one request | Maximum dimension 2000 or lower before the agent reads them |
| PDFs and screen recordings from the same task | Request size caps: 32 MB on standard Claude endpoints | PDF preset Small or Medium; video MP4, H.265, quality High or Web |
How do I compress images with Claude Code?
Connect Smol once, then ask in plain language. Smol’s MCP server gives Claude Code compress, convert, upscale and strip-metadata tools with real parameters: format, quality, resize, output location and metadata handling. You describe the result; the agent calls the tool.
If you want Claude Code to compress images without a tool like that, it falls back on whatever is installed: sips, ImageMagick, cwebp or a Node package. That works for one file. The weak point is repeatability. Each run picks its own quality, and the agent reads its own shell output instead of a structured result. An MCP tool makes the settings explicit and the output checkable, so two runs a week apart produce the same kind of file. Our guide to compressing images before a commit covers why the repo is where this matters most.

What image limits do AI agents and Git hit?
The tightest ones are a per-image cap, a pixel cap and a repository cap. Each row links to the vendor’s own documentation, read on 11 October 2026. Model limits change with releases, so recheck a number before you build on it.
| Where | Limit | Source |
|---|---|---|
| Claude API, one image | 10 MB (base64-encoded); 8000 × 8000 px maximum | Anthropic vision |
| Amazon Bedrock and Google Cloud, one image | 5 MB (base64-encoded) | Anthropic vision |
| claude.ai, one message | 10 MB per image; 20 images per message | Anthropic vision |
| A request with more than 20 images | Neither side above 2000 px, or the request is rejected | Anthropic vision |
| Claude, resolution tiers | 1568 px long edge (standard); 2576 px (Claude 4.7 and later) | Anthropic vision |
| Claude API, whole request | 32 MB on standard endpoints; lower on some partner platforms | Anthropic vision |
| OpenAI image input | 512 MB total payload, 1,500 images per request; PNG, JPEG, WEBP, non-animated GIF | OpenAI images guide |
| Git push to GitHub | Warning above 50 MiB, block above 100 MiB | GitHub Docs |
Two points matter here. First, base64 adds about a third, so a 10 MB base64 cap means a file of roughly 7.5 MB, and the 5 MB cloud-platform cap means about 3.75 MB. Second, a bigger image does not buy more detail. Anthropic downsizes anything past the tier’s long edge: a 2000 × 1500 image becomes 1269 × 952 on the standard tier and costs 1564 visual tokens, against 3888 tokens on the high-resolution tier. Pre-resizing saves upload bytes either way.
How does an MCP server for image compression work?
The agent starts or connects to a local process and calls its tools by name. For an MCP server image compression tool, the work happens in that process, on your machine, so the files never need a network hop. Smol’s server is the app you already run.
Claude Code
Claude Code adds servers with claude mcp add [options] <name> -- <command>, and stores them in one of three scopes: local (the default, just you in this project), project (shared through .mcp.json) or user (every project, kept in ~/.claude.json), per the Claude Code MCP docs. Smol’s Connect button writes its own entry into the client’s settings, keeps your other servers, and declines to overwrite a file it cannot read safely.
Can Codex compress images the same way?
Yes. Codex uses the same protocol. Its docs give codex mcp add <name> -- <command> and a [mcp_servers.<name>] table in ~/.codex/config.toml, with a startup timeout of 10 seconds and a tool timeout of 60 seconds by default (Codex MCP docs). If one call runs long on a big folder, those two fields are the ones to raise. Smol also connects to Google Antigravity, added in Smol 1.0.35.
What does the agent get back?
Structured results, and the output budget matters. Claude Code warns when a tool returns more than 10,000 tokens and caps output at 25,000 by default, adjustable with MAX_MCP_OUTPUT_TOKENS. Ask the agent for a summary (file, size before, size after), not a dump of every field, when you process hundreds of files.
Which settings should the agent use?
Give the agent a table, not a vibe. Smol’s image default is quality 75 with metadata stripped, and it resizes to fit inside 2000 × 2000 px unless told otherwise, so say the size you want every time. The numbers below are starting points we chose, not measured thresholds. Look at one output before you run the folder.
| Task | Output | Quality | Maximum dimension |
|---|---|---|---|
| Photos or mockups you attach to a prompt | JPG | 80 | 1568 (standard tier) or 2576 |
| Screenshots with small text | Original format (PNG) or JPG | 85, then read the text | 1568, or leave larger |
| Website hero images | WebP or AVIF | 75 WebP; 65 AVIF | The widest your layout shows |
| Images before a git commit | Original format | 75 | 2000 (the default) |
| Batch of 100 or more for one agent task | JPG | 75 | 2000 or lower |
| A file that must land near a size | Neural target size, 4 to 4096 KB | Not applicable | Set by the size |
Screenshots deserve the extra care. Anthropic warns that heavy lossy compression “can introduce artifacts that are detrimental to model performance”, and says JPEG compression can make text difficult to read, so keep quality higher when the agent has to read the picture. Metadata is not a factor for the model: Anthropic states that Claude does not parse or receive image metadata. Stripping it still matters for what you publish.
Target size is a band, not a ceiling, and it is slow, about 28 seconds for one 768 × 512 image, so reserve it for the few files that miss a cap. For scale, on 24 small Kodak test photos (768 × 512 JPEGs, default settings) Smol’s JPEGs came out 69.3% smaller, and PNG compressed to AVIF at quality 65 saved 92.1%. Those are small film photographs, so your files will differ; the method is on the benchmark page.
How do I set up Smol with Claude Code or Codex?
It takes about two minutes, once per Mac.
Open Smol for AI
Launch Smol and choose “Smol for AI” in the sidebar.
Press Connect next to your client
Claude Code, Codex or Google Antigravity. Smol adds itself to that client’s MCP settings.
Copy the full AI guide into the agent
Use “Copy full AI guide” so the agent knows every tool, format and setting.
Give the task with the numbers in it
For example: compress the images in this absolute folder path to WebP at quality 75, maximum dimension 1600, and report size before and after per file.
Check the largest output and one image
Open the biggest result and one text-heavy screenshot. Fix the setting, not each file.
Commit the compressed copies
Outputs are copies with a
_compressedsuffix by default, so decide which set the repo keeps.

How do I automate image optimization and let an agent optimize assets?
Pick the trigger. An agent session handles a task on request. A watched folder handles files as they arrive. A Finder Quick Action handles a right-click. For a pipeline on a server, the answer is different.
- Inside an agent session: add a line to your project’s agent instructions such as “before committing images, compress them with Smol at quality 75”, so the agent applies the same settings each time. This is how an AI agent optimizes assets without a reminder.
- Watched folders: good for fresh screenshots and camera exports. They can make already-optimized files larger, so never point one at your repo’s assets folder. See the watched folder guide.
- Finder Quick Action: a right-click for humans on the team, described in adding a Compress Quick Action.
- CI on Linux: Smol is a Mac app and cannot run there. Use an image library in the build, or the Smol API for server-side compression.
For a team, Smol is $29 once for one Mac. Team is $49 once for three Macs, and Enterprise is $20 a seat for 5 to 500 seats, managed from one dashboard. There is no subscription and no per-file cap. Presets are saved on each Mac, so write your settings in the repo’s agent instructions and have each developer recreate the preset. Framework-specific advice is in Next.js and React image assets, and README images are covered in GitHub README media.
What do developers use to compress images today?
Start with what is free and already there. The comparison below is fair to each option.
| Option | Cost | Strength | Weakness |
|---|---|---|---|
| sips (built in) | Free | Fast: 24 small images in under one second in our test | Resizes and converts; the agent writes the command each time |
| Agent-written scripts with cwebp, ImageMagick or sharp | Free | Fits a Node or CI build; fully scriptable | You maintain it; settings drift between runs; PDFs and video need other tools |
| Hosted MCP servers or web APIs | Varies | Works from any OS | Files leave your machine; limits depend on the plan |
| Smol over MCP | $29 once | Images, PDFs, video and audio in one tool with explicit settings; local | Mac only; not the fastest: 24 small images take about 7 seconds |
More on the built-in option is in the sips command guide, and the full methods comparison tests the rest. Our web developer guide covers formats and delivery.
When is Smol the wrong tool for an agent?
Your pipeline runs on Linux or in CI. Smol is macOS only and is not a build-time tool. Put an image library in the build, or use the Smol API.
You need lossless output. Smol always re-encodes images and has no lossless mode. For pixel-identical results, ImageOptim is the answer, shown in our head-to-head test.
You need SVG, JPEG XL or responsive sets. Smol writes neither SVG nor JPEG XL, and one job produces one size, so several widths of one image take separate runs.
You compress a file every few weeks. Open Smol and drag it in. The MCP layer pays off when the work repeats or already happens inside an editor session. For other teams on the Mac, the web agencies page covers client sites.
Frequently asked questions
Can Claude Code compress images by itself?
Yes, by writing a shell command with a tool such as sips, ImageMagick or cwebp, which works for single files. The weak point is repeatability: quality is chosen per run and the agent reads shell text. Connecting an MCP server such as Smol gives it explicit settings and structured per-file results, and the files stay on your Mac.
How do I compress images with Codex?
Add an MCP server the same way you would for any tool. Codex documents the command codex mcp add with the start command after two dashes, and a table per server in ~/.codex/config.toml. In Smol, press Connect next to Codex in the Smol for AI panel, then ask for the compression with a quality and a maximum dimension.
What image size does Claude accept?
Anthropic lists 10 MB per image on the Claude API, counted base64-encoded, so roughly 7.5 MB as a file, plus 8000 by 8000 pixels. Claude also downsizes past a long edge of 1568 pixels on the standard tier and 2576 on newer models. Check the vision docs for your model, because limits change.
Are my files uploaded when an agent uses Smol?
No. The MCP server runs inside the Smol app on your Mac. The agent connects to that local server, and files are read and written on your own disk. Your AI provider still sees whatever text or images you put in the conversation itself, so be careful what you attach to prompts.
Can an agent change my license or overwrite my originals?
No on both counts. License activation, deactivation and update installs are excluded from the MCP surface. Smol writes a copy with a _compressed suffix by default and does not overwrite originals unless you change the setting. Every path the agent supplies must be absolute, which prevents wrong-directory mistakes.
Should the agent compress PNG screenshots to JPG?
Only if the agent does not need to read small text in them. Anthropic notes that heavy JPEG compression can make text difficult to read. Start at quality 85, keep the original format when text matters, check one output, and resize to the model’s long edge of 1568 pixels rather than shrinking quality further.
Keep reading
Smol for other teams