decode

Decodes a PNG or JPEG file held in bytes into a new image. Images with fewer channels are expanded to RGBA, with opaque alpha when the file has none.

bytes is only read during the call and never retained, so the caller may reuse it.

Has no sample because it needs a file on disk.

Throws

if bytes is empty, is not a PNG or JPEG file, or is corrupt.