The previous implementation was producing invalid image data with
wrong magic bytes (d0 e5 67 00 instead of 52 49 46 46 for WebP).
Root cause: Incorrect usage of ImageMagick write API.
Changes:
- Set image.format BEFORE writing (tells ImageMagick the output format)
- Simplified write() call to: image.write((data) => data)
- This returns the correctly formatted image data
The proper pattern is:
1. Set image.format = outputFormatEnum
2. Apply transformations (quality, resize)
3. Call image.write() which returns the encoded data
This should now produce valid WebP files with correct RIFF header
(52 49 46 46) and allow the preview to display properly.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>