The image in any supported format.
A Buffer containing the raw image bytes.
When input is neither a string nor a Buffer.
When a remote URL fetch fails or the file cannot be read.
const buf1 = await imageToBuffer('data:image/png;base64,iVBOR...');
const buf2 = await imageToBuffer(fs.readFileSync('photo.png'));
const buf3 = await imageToBuffer('https://example.com/photo.png');
const buf4 = await imageToBuffer('/absolute/path/to/image.jpg');
Converts an image input from any of the supported formats into a
Buffer.Supported input formats:
Buffer— returned as-is.data:image/png;base64,iVBOR.... The base64 payload is extracted and decoded.file://URL — resolved to a local filesystem path and read.globalThis.fetchand buffered.fs.readFile.