# OfficeHeifMetadataReader

Reads and replaces HEIF/HEIC item metadata without decoding image pixels.

Class 

`OfficeIMO.Drawing`

**Namespace**

`OfficeIMO.Drawing`

**Assembly**

`OfficeIMO.Core`

**Source revision**

`15caddadea70` with working tree changes

**Source**

[OfficeHeifMetadataReader.cs:28](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.cs#L28)

**Modifiers**

static

Reads and replaces HEIF/HEIC item metadata without decoding image pixels.

## Inheritance

- object
- OfficeHeifMetadataReader

## Remarks

Encoded input and output are bounded to 128 MiB, individual metadata/property payloads to 16 MiB, declared item collections to 4,096 entries, and parser work to 65,536 records. Rewriting replaces or clears an existing single file-backed extent. Item-data-box, external, derived and multiple-extent items are readable where supported but not writable. Each metadata family is inspected independently; unchanged siblings are preserved as bytes. Reads and writes select a unique metadata item associated with the primary image through cdsc references. A sole unassociated metadata item remains supported for older containers; ambiguous or explicitly unrelated items are not selected. Information retains all declared items, while incomplete declared collections are rejected without returning partial results. Protected items and XMP items declaring a content encoding remain discoverable, but their payload reads and writes (including clearing) are unsupported. Stream reads include known caller-owned memory backing in the operation's managed working-set budget. XMP writes also account for the supplied UTF-16 string in that budget. XMP reads reject malformed UTF-8, and writes reject strings containing unpaired UTF-16 surrogates. A valid new packet can replace an existing malformed requested payload.

Filter members 

Show inherited

## Methods

HasExifItem 2 overloads

`public static bool HasExifItem(byte[] data, CancellationToken cancellationToken = default)` [#](#method-hasexifitem-byte-threading-cancellationtoken)

[OfficeHeifMetadataReader.cs:52](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.cs#L52)

Returns whether the container declares an EXIF item, even if its payload is unlocated.

Parameters

**data byte[] required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`bool`

`public static bool HasExifItem(string filePath, CancellationToken cancellationToken = default)` [#](#method-hasexifitem-string-threading-cancellationtoken)

[OfficeHeifMetadataReader.cs:117](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.cs#L117)

Returns whether a bounded file declares an EXIF item.

Parameters

**filePath string required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`bool`

HasXmpItem 2 overloads

`public static bool HasXmpItem(byte[] data, CancellationToken cancellationToken = default)` [#](#method-hasxmpitem-byte-threading-cancellationtoken)

[OfficeHeifMetadataReader.cs:56](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.cs#L56)

Returns whether the container declares an XMP item, even if its payload is unlocated.

Parameters

**data byte[] required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`bool`

`public static bool HasXmpItem(string filePath, CancellationToken cancellationToken = default)` [#](#method-hasxmpitem-string-threading-cancellationtoken)

[OfficeHeifMetadataReader.cs:121](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.cs#L121)

Returns whether a bounded file declares an XMP item.

Parameters

**filePath string required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`bool`

TryReadExifProfile 3 overloads

`public static bool TryReadExifProfile(byte[] data, out OfficeImageMetadata? profile, CancellationToken cancellationToken = default)` [#](#method-tryreadexifprofile-byte-officeimo-drawing-officeimagemetadata-threading-cancellationtoken)

[OfficeHeifMetadataReader.cs:36](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.cs#L36)

Reads the existing EXIF item through the shared typed EXIF codec.

Parameters

**data byte[] required**

**profile OfficeIMO.Drawing.OfficeImageMetadata? required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`bool`

`public static bool TryReadExifProfile(Stream source, out OfficeImageMetadata? profile, CancellationToken cancellationToken = default)` [#](#method-tryreadexifprofile-io-stream-officeimo-drawing-officeimagemetadata-threading-cancellationtoken)

[OfficeHeifMetadataReader.cs:87](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.cs#L87)

Reads EXIF from the current stream position, restoring seekable streams and leaving them open.

Parameters

**source System.IO.Stream required**

**profile OfficeIMO.Drawing.OfficeImageMetadata? required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`bool`

`public static bool TryReadExifProfile(string filePath, out OfficeImageMetadata? profile, CancellationToken cancellationToken = default)` [#](#method-tryreadexifprofile-string-officeimo-drawing-officeimagemetadata-threading-cancellationtoken)

[OfficeHeifMetadataReader.cs:109](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.cs#L109)

Reads an existing EXIF item from a bounded file.

Parameters

**filePath string required**

**profile OfficeIMO.Drawing.OfficeImageMetadata? required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`bool`

TryReadInfo 3 overloads

`public static bool TryReadInfo(byte[] data, out OfficeHeifImageInfo? info, CancellationToken cancellationToken = default)` [#](#method-tryreadinfo-byte-officeimo-drawing-officeheifimageinfo-threading-cancellationtoken)

[OfficeHeifMetadataReader.cs:28](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.cs#L28)

Reads container brands, primary image properties, items, locations and references.

Parameters

**data byte[] required**

**info OfficeIMO.Drawing.OfficeHeifImageInfo? required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`bool`

`public static bool TryReadInfo(Stream source, out OfficeHeifImageInfo? info, CancellationToken cancellationToken = default)` [#](#method-tryreadinfo-io-stream-officeimo-drawing-officeheifimageinfo-threading-cancellationtoken)

[OfficeHeifMetadataReader.cs:78](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.cs#L78)

Reads container information from the current stream position, restoring seekable streams and leaving them open.

Parameters

**source System.IO.Stream required**

**info OfficeIMO.Drawing.OfficeHeifImageInfo? required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`bool`

`public static bool TryReadInfo(string filePath, out OfficeHeifImageInfo? info, CancellationToken cancellationToken = default)` [#](#method-tryreadinfo-string-officeimo-drawing-officeheifimageinfo-threading-cancellationtoken)

[OfficeHeifMetadataReader.cs:105](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.cs#L105)

Reads bounded container information from a file.

Parameters

**filePath string required**

**info OfficeIMO.Drawing.OfficeHeifImageInfo? required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`bool`

TryReadXmp 3 overloads

`public static bool TryReadXmp(byte[] data, out string? xmp, CancellationToken cancellationToken = default)` [#](#method-tryreadxmp-byte-string-threading-cancellationtoken)

[OfficeHeifMetadataReader.cs:44](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.cs#L44)

Reads an existing XMP item's UTF-8 packet without parsing its EXIF sibling.

Parameters

**data byte[] required**

**xmp string? required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`bool`

`public static bool TryReadXmp(Stream source, out string? xmp, CancellationToken cancellationToken = default)` [#](#method-tryreadxmp-io-stream-string-threading-cancellationtoken)

[OfficeHeifMetadataReader.cs:96](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.cs#L96)

Reads XMP from the current stream position, restoring seekable streams and leaving them open.

Parameters

**source System.IO.Stream required**

**xmp string? required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`bool`

`public static bool TryReadXmp(string filePath, out string? xmp, CancellationToken cancellationToken = default)` [#](#method-tryreadxmp-string-string-threading-cancellationtoken)

[OfficeHeifMetadataReader.cs:113](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.cs#L113)

Reads an existing XMP item from a bounded file.

Parameters

**filePath string required**

**xmp string? required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`bool`

TryWriteExifProfile 2 overloads

`public static bool TryWriteExifProfile(byte[] data, OfficeImageMetadata? profile, out byte[]? output, CancellationToken cancellationToken = default)` [#](#method-trywriteexifprofile-byte-officeimo-drawing-officeimagemetadata-byte-threading-cancellationtoken)

[OfficeHeifMetadataReader.cs:61](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.cs#L61)

Replaces or clears an existing writable EXIF item and returns independently owned container bytes.

Parameters

**data byte[] required**

**profile OfficeIMO.Drawing.OfficeImageMetadata? required**

**output byte[]? required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`bool`

`public static bool TryWriteExifProfile(string filePath, string outputPath, OfficeImageMetadata? profile, CancellationToken cancellationToken = default)` [#](#method-trywriteexifprofile-string-string-officeimo-drawing-officeimagemetadata-threading-cancellationtoken)

[OfficeHeifMetadataReader.cs:126](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.cs#L126)

Replaces or clears an existing writable EXIF item in a file.

Parameters

**filePath string required**

**outputPath string required**

**profile OfficeIMO.Drawing.OfficeImageMetadata? required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`bool`

`public static bool TryWriteMetadata(byte[] data, OfficeImageMetadata? metadata, OfficeImageMetadataProfileKinds profiles, out byte[]? output, CancellationToken cancellationToken = default)` [#](#method-trywritemetadata-byte-officeimo-drawing-officeimagemetadata-officeimo-drawing-officeimagemetadataprofilekinds-byte-threading-cancellationtoken)

[OfficeHeifMetadataReader.CombinedWriting.cs:25](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.CombinedWriting.cs#L25)

Replaces or clears selected existing HEIF EXIF and XMP profiles without decoding pixels.

Parameters

**data byte[] required**

Encoded input bytes, which remain unchanged.

**metadata OfficeIMO.Drawing.OfficeImageMetadata? required**

Replacement profiles. Null clears every selected profile; a missing selected profile also clears its item.

**profiles OfficeIMO.Drawing.OfficeImageMetadataProfileKinds required**

The EXIF and XMP families to edit. None returns an independent unchanged copy.

**output byte[]? required**

Independently owned complete output on success, or null when any selected edit is rejected.

**cancellationToken System.Threading.CancellationToken = default optional**

Cancellation observed during parsing, encoding, and copying.

Returns

`bool` True only when every selected edit completes within the resource limits.

Exceptions

- `ArgumentNullException` – Data is null.
- `ArgumentOutOfRangeException` – Profiles contains a family other than EXIF or XMP.
- `OperationCanceledException` – The operation is cancelled.

TryWriteXmp 2 overloads

`public static bool TryWriteXmp(byte[] data, string? xmp, out byte[]? output, CancellationToken cancellationToken = default)` [#](#method-trywritexmp-byte-string-byte-threading-cancellationtoken)

[OfficeHeifMetadataReader.cs:70](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.cs#L70)

Replaces or clears an existing writable XMP item and returns independently owned container bytes.

Parameters

**data byte[] required**

**xmp string? required**

**output byte[]? required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`bool`

`public static bool TryWriteXmp(string filePath, string outputPath, string? xmp, CancellationToken cancellationToken = default)` [#](#method-trywritexmp-string-string-string-threading-cancellationtoken)

[OfficeHeifMetadataReader.cs:136](https://github.com/EvotecIT/OfficeIMO/blob/15caddadea7080f6e4b3027fdb95451a0210bdb1/OfficeIMO.Core/Raster/Heif/OfficeHeifMetadataReader.cs#L136)

Replaces or clears an existing writable XMP item in a file.

Parameters

**filePath string required**

**outputPath string required**

**xmp string? required**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`bool`

## Inherited Methods

`public virtual bool Equals(object? obj)` [#](#method-equals-object)

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

`public virtual int GetHashCode()` [#](#method-gethashcode)

Inherited from object

Returns

`int`

`public Type GetType()` [#](#method-gettype)

Inherited from object

Returns

`Type`

`public virtual string? ToString()` [#](#method-tostring)

Inherited from object

Returns

`string?`

<!-- PowerForge markdown artifact sha256:103B9D8D554CCB87298E3ADFB75A55F3DFB8CCA6F0B89B07E1737A1AC66E247C -->
