fix: set image format before calling write() in ImageMagick
The correct API pattern is: 1. Set image.format = outputFormatEnum first 2. Then call image.write(callback) with the format already set This ensures the image is written in the correct format with proper headers (RIFF for WebP, etc.) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -39,6 +39,9 @@ export async function convertWithImageMagick(
|
|||||||
let result: Uint8Array | undefined;
|
let result: Uint8Array | undefined;
|
||||||
|
|
||||||
await ImageMagick.read(inputData, (image) => {
|
await ImageMagick.read(inputData, (image) => {
|
||||||
|
// Set output format
|
||||||
|
image.format = outputFormatEnum;
|
||||||
|
|
||||||
// Apply quality setting if specified
|
// Apply quality setting if specified
|
||||||
if (options.imageQuality !== undefined) {
|
if (options.imageQuality !== undefined) {
|
||||||
image.quality = options.imageQuality;
|
image.quality = options.imageQuality;
|
||||||
@@ -65,8 +68,10 @@ export async function convertWithImageMagick(
|
|||||||
|
|
||||||
if (onProgress) onProgress(70);
|
if (onProgress) onProgress(70);
|
||||||
|
|
||||||
// Write the image data with the specified format
|
// Write the image data in the specified format
|
||||||
result = image.write(outputFormatEnum);
|
image.write((data) => {
|
||||||
|
result = data;
|
||||||
|
});
|
||||||
|
|
||||||
if (onProgress) onProgress(90);
|
if (onProgress) onProgress(90);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user