[BUG] JPEG images silently converted to PNG in VS Code extension, causing 5MB API limit errors
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When attaching a JPEG image in Claude Code (VS Code extension), the image is silently converted to PNG format before being sent to the API. This causes images that are well within acceptable file sizes as JPEG to exceed the 5MB API limit as PNG.
Steps to Reproduce
Have a JPEG image file on disk (e.g. a screenshot saved as .jpg)
Attach it to the Claude Code chat in VS Code (via the paperclip button or drag & drop)
Observe the error: Image base64 size (5.2MB) exceeds API limit (5MB). Please resize the image before sending.
Expected Behavior
JPEG images should be sent to the API as JPEG, preserving the original format and file size.
Actual Behavior
The extension converts JPEG to PNG internally before encoding to base64. This inflates the file size dramatically — in my case, a 92 KB JPEG becomes 5.2 MB PNG, a ~56x size increase, causing it to exceed the 5MB API limit.
Impact
Any JPEG image that is reasonably large in resolution (e.g. Retina screenshots) will fail to send, even if the original file is tiny. This makes it practically impossible to attach screenshots taken on macOS (which saves them as JPEG by default) without manual workarounds.
Suggested Fix
Detect the original image format and preserve it when encoding to base64. If the source file is JPEG, send it as JPEG — do not convert to PNG.
What Should Happen?
JPEG images should be sent to the API as JPEG, preserving the original format and file size. A 92 KB JPEG file should arrive at the API as ~92 KB, not be inflated to 5.2 MB by conversion to PNG.
Error Messages/Logs
Steps to Reproduce
- Have any JPEG image file on disk (e.g. a screenshot saved as .jpg, 92 KB)
- Open Claude Code in VS Code on macOS
- Attach the JPEG file using the paperclip button
- Error appears: "Image base64 size (5.2MB) exceeds API limit (5MB). Please resize the image before sending."
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
claude --version
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗