readMetadata
The EXIF block, XMP packet and ICC profile of a JPEG, PNG, WebP, JP2, AVIF, HEIC, TIFF, JPEG XL, JPEG XR, GIF or BMP file. The encoders that take an ImageMetadata write them again, so a re-encode keeps them (#129, #186). A JP2 file keeps the XMP and EXIF in UUID boxes and the profile in its colour specification (#180). A HEIF file gives those of its primary image (#149); its orientation is in irot and imir, which decode applies, never in the EXIF tag. The gain map of an Ultra HDR JPEG comes too, found through its Multi-Picture Format segment (#130); the gain map of a HEIF file, which needs a decode, comes from decodeGainMap (#153).
A TIFF or JPEG XR file has no EXIF block of its own: its first directory points to EXIF and GPS directories, and the block given is built of those and of the directory's descriptive tags, little endian, and only when it points to either. A JPEG XL file gives its Exif and xml boxes, also from a Brotli-compressed brob box, and the profile of its codestream. A GIF gives its XMP and ICC application extensions, and a BMP the profile of a BITMAPV5HEADER.
A file of another format, or one that has none, gives empty metadata; a damaged segment, chunk or box is left out.