Dicom.P10.FileMeta (Dicom v0.9.1)

Copy Markdown View Source

DICOM P10 File Meta Information (Group 0002).

The File Meta Information header is always encoded in Explicit VR Little Endian regardless of the Transfer Syntax used for the data set.

Reference: DICOM PS3.10 Section 7.1.

Summary

Functions

Generates a P10 preamble (128 zero bytes + "DICM").

Sanitizes the preamble by zeroing it out.

Validates and skips the 128-byte preamble and "DICM" magic.

Validates the preamble content per PS3.10 Section 7.5.

Functions

preamble()

@spec preamble() :: binary()

Generates a P10 preamble (128 zero bytes + "DICM").

sanitize_preamble(arg1)

@spec sanitize_preamble(binary()) :: {:ok, binary()} | {:error, :invalid_preamble}

Sanitizes the preamble by zeroing it out.

Per PS3.10 Section 7.5, the preamble can contain malicious content. This function replaces the 128-byte preamble with zeros while preserving the DICM prefix and all subsequent data.

skip_preamble(arg1)

@spec skip_preamble(binary()) :: {:ok, binary()} | {:error, :invalid_preamble}

Validates and skips the 128-byte preamble and "DICM" magic.

Returns the remaining binary after the preamble, or an error.

validate_preamble(arg1)

@spec validate_preamble(binary()) ::
  :ok | {:warning, :non_standard_preamble} | {:error, :invalid_preamble}

Validates the preamble content per PS3.10 Section 7.5.

Returns:

  • :ok if preamble is all zeros or starts with recognized dual-format magic (TIFF)
  • {:warning, :non_standard_preamble} if preamble contains non-standard content
  • {:error, :invalid_preamble} if the binary is not a valid DICOM file