Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

OfficeHeifMetadataReader

OfficeIMO.Drawing

Namespace
OfficeIMO.Drawing
Assembly
OfficeIMO.Core
Source revision
1f76172c94d1 with working tree changes
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.

Methods

HasExifItem 2 overloads
public static bool HasExifItem(byte[] data, CancellationToken cancellationToken = default) #

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) #

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) #

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) #

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) #

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) #

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) #

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) #

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) #

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) #

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) #

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) #

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) #

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) #

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) #

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) #

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) #

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) #

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