Skip to content

parseHeader

function parseHeader(bytes, options?): ParseHeaderResult;

Defined in: header/parse-header.ts:59

Parse a FITS header from the start of bytes.

Walks the 2880-byte header blocks, parsing 80-character cards until the END keyword, and resolves the CONTINUE long-string convention. The byte source is not consulted beyond the header, so this works on an in-memory buffer; streaming and random-access readers are layered on top elsewhere.

Parameter Type
bytes Uint8Array
options ParseHeaderOptions

ParseHeaderResult

Read keywords from a primary header

import { parseHeader } from "@fits-js/core";
const { header, byteLength } = parseHeader(bytes);
header.getNumber("NAXIS"); // 2
header.getString("OBJECT"); // "M51"
// pixel data begins at byteLength

FITS Standard v4.0 §4: Headers