Skip to main content

readPngSize

Reads the pixel size from the start of a PNG blob: the fake's header or a real file. Gives undefined for bytes that are not the start of a PNG (too short, no signature, or no IHDR chunk first), so a test fails on what it was given rather than on a number read from nowhere.

This is a function exported by @mapcairn/core, checked against version 0.2.0.

Signature​

import { readPngSize } from "@mapcairn/core";

function readPngSize(blob: Blob): Promise<{
readonly width: number;
readonly height: number;
} | undefined>;

Parameters​

  • blob (Blob)

Returns​

Promise<{ readonly width: number; readonly height: number; } | undefined>

Source: packages/core/src/fakes/pngHeader.ts:52