fix: pass format as first argument to image.write()

The correct ImageMagick WASM API is:
image.write(format, callback)

Where the format is passed as the first argument and the callback
receives the encoded data. This should produce valid WebP with
correct RIFF headers.

🤖 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:49:41 +01:00
parent 7a15a15e50
commit a43a336965

View File

@@ -39,9 +39,6 @@ export async function convertWithImageMagick(
let result: Uint8Array | undefined;
await ImageMagick.read(inputData, (image) => {
// Set output format
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 in the specified format
image.write((data) => {
// Write the image data with format
image.write(outputFormatEnum, (data) => {
result = data;
});