[BUG] The Write tool incorrectly saves binary image files as ASCII text instead of preserving the binary format, causing Next.js Image components to display alt text rather than the actual images.

Resolved 💬 3 comments Opened Aug 24, 2025 by HimaSphere Closed Jan 7, 2026

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: <!-- output of claude --version -->
  • Operating System: Linux 6.16.2-2-cachyos
  • Terminal: Claude Code CLI

## Bug Description
The Write tool incorrectly saves binary image files (WebP, PNG, JPG) as ASCII text instead of preserving the binary format. This causes web frameworks like Next.js to display alt text instead of rendering the actual images.

## Steps to Reproduce

  1. Use the Write tool to save a binary image file (e.g., WebP format)
  2. Provide image content through Claude Code's multimodal input
  3. Use Write tool with a .webp file extension
  4. Check the saved file with file command
  5. Observe that it's saved as "ASCII text" instead of proper image format

## Expected Behavior
Binary image files should be saved in their original binary format, maintaining proper image headers and data structure that can be read by web browsers and image processing tools.

## Actual Behavior
Binary images are converted to ASCII text format during the Write operation. When used in Next.js <Image> components, the browser cannot parse the corrupted file and falls back to displaying the alt text instead of the image.

## Additional Context

  • Verified with file command: shows "ASCII text, with no line terminators" instead of "RIFF (little-endian) data, Web/P image"
  • Affects web development workflows where images need to be programmatically saved
  • Workaround: Use external tools like ImageMagick (magick convert) to create proper binary image files
  • Issue discovered while implementing WebP logo support in Next.js application
  • The Read tool correctly handles binary images for viewing, but Write tool corrupts them during save operations

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗