Converts an ImageData object into a Blob in PNG format.
This operation is asynchronous and uses OffscreenCanvas to perform the encoding, making it suitable for usage in both the main thread and Web Workers.
The pixel data to be encoded.
A promise that resolves to a Blob with the MIME type image/png.
image/png
Thrown if the OffscreenCanvas context cannot be initialized or the blob encoding fails.
const blob = await imageDataToImgBlob(imageData);const url = URL.createObjectURL(blob); Copy
const blob = await imageDataToImgBlob(imageData);const url = URL.createObjectURL(blob);
Converts an ImageData object into a Blob in PNG format.
This operation is asynchronous and uses OffscreenCanvas to perform the encoding, making it suitable for usage in both the main thread and Web Workers.