fix: use correct ImageMagick write API to produce valid output format

Changed from image.write((data) => data) callback pattern to
image.write(outputFormatEnum) which correctly writes the image data
in the specified format. This should now produce valid WebP files
with proper RIFF headers (52 19 46 46 magic bytes).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-17 12:37:13 +01:00
parent b9f9a7bea6
commit 58206d5b18

View File

@@ -39,9 +39,6 @@ export async function convertWithImageMagick(
let result: Uint8Array | undefined;
await ImageMagick.read(inputData, (image) => {
// Set the output format first
image.format = outputFormatEnum;
// Apply quality setting if specified
if (options.imageQuality !== undefined) {
image.quality = options.imageQuality;
@@ -68,8 +65,8 @@ export async function convertWithImageMagick(
if (onProgress) onProgress(70);
// Write the image data
result = image.write((data) => data);
// Write the image data with the specified format
result = image.write(outputFormatEnum);
if (onProgress) onProgress(90);
});