fix(coding-agent/utils): corrected buffer encoding in image utilities

- Corrected buffer-to-base64 conversion by wrapping raw buffers with Buffer.from() to ensure proper encoding across image processing utilities.
- Updated 6 buffer conversion calls in fetch, image-input, and image-resize modules for consistency.
This commit is contained in:
can1357
2026-03-11 16:59:50 +01:00
parent 86fe8d2e2f
commit afcb2ec52a
3 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -714,7 +714,7 @@ async function renderUrl(url: string, timeout: number, raw: boolean, signal?: Ab
}
const resized = await resizeImage(
{ type: "image", data: binary.buffer.toBase64(), mimeType: imageMimeType },
{ type: "image", data: Buffer.from(binary.buffer).toBase64(), mimeType: imageMimeType },
{ maxBytes: MAX_INLINE_IMAGE_OUTPUT_BYTES },
);
const isDecodedImage =
@@ -231,7 +231,7 @@ export async function loadImageInput(options: LoadImageInputOptions): Promise<Lo
throw new ImageInputTooLargeError(inputBuffer.byteLength, maxBytes);
}
let outputData = new Uint8Array(inputBuffer).toBase64();
let outputData = Buffer.from(inputBuffer).toBase64();
let outputMimeType = mimeType;
let outputBytes = inputBuffer.byteLength;
let dimensionNote: string | undefined;
@@ -136,7 +136,7 @@ export async function resizeImage(img: ImageContent, options?: ImageResizeOption
height: finalHeight,
wasResized: true,
get data() {
return best.buffer.toBase64();
return Buffer.from(best.buffer).toBase64();
},
};
}
@@ -155,7 +155,7 @@ export async function resizeImage(img: ImageContent, options?: ImageResizeOption
height: finalHeight,
wasResized: true,
get data() {
return best.buffer.toBase64();
return Buffer.from(best.buffer).toBase64();
},
};
}
@@ -183,7 +183,7 @@ export async function resizeImage(img: ImageContent, options?: ImageResizeOption
height: finalHeight,
wasResized: true,
get data() {
return best.buffer.toBase64();
return Buffer.from(best.buffer).toBase64();
},
};
}
@@ -200,7 +200,7 @@ export async function resizeImage(img: ImageContent, options?: ImageResizeOption
height: finalHeight,
wasResized: true,
get data() {
return best.buffer.toBase64();
return Buffer.from(best.buffer).toBase64();
},
};
} catch {