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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user