hdrSizeOf function

({int height, int width})? hdrSizeOf(
  1. Uint8List bytes
)

How big bytes says it is, without decoding a pixel of it — ux-49.

The header is a few dozen bytes and the image is megabytes. What asks this is a check — "is this panorama twice as wide as it is tall" — and decoding four million floats to answer it would make a refusal cost more than an acceptance.

Null for anything readHdr would refuse, without saying why: a caller that wants the reason calls readHdr and catches it.

Implementation

({int width, int height})? hdrSizeOf(Uint8List bytes) {
  try {
    final _Header header = _readHeader(bytes);
    return (width: header.width, height: header.height);
  } on HdrFormatException {
    return null;
  }
}