# OfficeImageReader

Bounded image metadata reader used to avoid full image decoding dependencies.

Class 

`OfficeIMO.Drawing`

**Namespace**

`OfficeIMO.Drawing`

**Assembly**

`OfficeIMO.Core`

**Source revision**

`ba882f6b0d07` with working tree changes

**Source**

[OfficeImageReader.cs:51](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeImageReader.cs#L51)

**Modifiers**

static

Bounded image metadata reader used to avoid full image decoding dependencies.

## Inheritance

- object
- OfficeImageReader

Filter members 

Show inherited

## Methods

`public static OfficeImageFormat FromExtension(string? fileName)` [#](#method-fromextension-string)

[OfficeImageReader.cs:311](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeImageReader.cs#L311)

Maps a file name or extension to a supported image format.

Parameters

**fileName string? required**

Returns

`OfficeImageFormat`

Identify 2 overloads

`public static OfficeImageInfo Identify(string filePath)` [#](#method-identify-string)

[OfficeImageReader.cs:51](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeImageReader.cs#L51)

Identifies image metadata from a file.

Parameters

**filePath string required**

Returns

`OfficeImageInfo`

`public static OfficeImageInfo Identify(byte[] data, string? fileName = null)` [#](#method-identify-byte-string)

[OfficeImageReader.cs:63](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeImageReader.cs#L63)

Identifies image metadata from a byte array.

Parameters

**data byte[] required**

**fileName string? = null optional**

Returns

`OfficeImageInfo`

`public static bool IsKnownImageExtension(string? fileName)` [#](#method-isknownimageextension-string)

[OfficeImageReader.cs:353](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeImageReader.cs#L353)

Returns whether the file name or extension maps to an image format known by the shared drawing layer.

Parameters

**fileName string? required**

File name, path, or bare extension.

Returns

`bool` true when the extension maps to a known image format.

`public static byte[] NormalizeForEmbedding(byte[] encodedBytes, OfficeRasterDecodeOptions? options, out OfficeImageInfo info)` [#](#method-normalizeforembedding-byte-officeimo-drawing-officerasterdecodeoptions-officeimo-drawing-officeimageinfo)

[OfficeImageReader.Embedding.cs:9](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeImageReader.Embedding.cs#L9)

Converts HEIC still images to PNG for Office document embedding, leaving other recognized formats unchanged.

Parameters

**encodedBytes byte[] required**

**options OfficeIMO.Drawing.OfficeRasterDecodeOptions? required**

**info OfficeIMO.Drawing.OfficeImageInfo required**

Returns

`byte[]`

Exceptions

- `NotSupportedException` – The required system codec is unavailable or the HEIC profile is unsupported.

TryIdentify 2 overloads

`public static bool TryIdentify(Stream stream, string? fileName, out OfficeImageInfo info)` [#](#method-tryidentify-io-stream-string-officeimo-drawing-officeimageinfo)

[OfficeImageReader.cs:74](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeImageReader.cs#L74)

Tries to identify image metadata from a stream.

Parameters

**stream System.IO.Stream required**

**fileName string? required**

**info OfficeIMO.Drawing.OfficeImageInfo required**

Returns

`bool`

`public static bool TryIdentify(byte[]? data, string? fileName, out OfficeImageInfo info)` [#](#method-tryidentify-byte-string-officeimo-drawing-officeimageinfo)

[OfficeImageReader.cs:154](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeImageReader.cs#L154)

Tries to identify image metadata from a byte array.

Parameters

**data byte[]? required**

**fileName string? required**

**info OfficeIMO.Drawing.OfficeImageInfo required**

Returns

`bool`

TryIdentifyByContent 2 overloads

`public static bool TryIdentifyByContent(Stream stream, string? fileName, out OfficeImageInfo info)` [#](#method-tryidentifybycontent-io-stream-string-officeimo-drawing-officeimageinfo)

[OfficeImageReader.cs:83](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeImageReader.cs#L83)

Tries to identify image metadata from a stream while requiring the content to match a supported format. The file name may select a content parser but cannot identify the image by extension alone.

Parameters

**stream System.IO.Stream required**

**fileName string? required**

**info OfficeIMO.Drawing.OfficeImageInfo required**

Returns

`bool`

`public static bool TryIdentifyByContent(byte[]? data, string? fileName, out OfficeImageInfo info)` [#](#method-tryidentifybycontent-byte-string-officeimo-drawing-officeimageinfo)

[OfficeImageReader.cs:170](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeImageReader.cs#L170)

Tries to identify image metadata from a byte array while requiring the content to match a supported format. The file name may select a content parser but cannot identify the image by extension alone.

Parameters

**data byte[]? required**

**fileName string? required**

**info OfficeIMO.Drawing.OfficeImageInfo required**

Returns

`bool`

`public static bool TryReadBase64DataUri(string? source, long maximumImageBytes, out byte[] bytes, out OfficeImageInfo info)` [#](#method-tryreadbase64datauri-string-int64-byte-officeimo-drawing-officeimageinfo)

[OfficeImageReader.DataUris.cs:8](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeImageReader.DataUris.cs#L8)

Decodes and validates a bounded base64 PNG, JPEG or SVG data URI.

Parameters

**source string? required**

**maximumImageBytes long required**

**bytes byte[] required**

**info OfficeIMO.Drawing.OfficeImageInfo required**

Returns

`bool`

TryValidateContent 4 overloads

`public static bool TryValidateContent(Stream stream, string? fileName, out OfficeImageInfo info)` [#](#method-tryvalidatecontent-io-stream-string-officeimo-drawing-officeimageinfo)

[OfficeImageReader.cs:92](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeImageReader.cs#L92)

Validates a complete bounded image payload and returns its metadata. Unlike metadata identification, this decodes supported PNG, JPEG, GIF, BMP, TIFF, WebP, and AVIF payloads and validates every ICO entry so structurally plausible but incomplete image bodies are rejected.

Parameters

**stream System.IO.Stream required**

**fileName string? required**

**info OfficeIMO.Drawing.OfficeImageInfo required**

Returns

`bool`

`public static bool TryValidateContent(Stream stream, string? fileName, CancellationToken cancellationToken, out OfficeImageInfo info)` [#](#method-tryvalidatecontent-io-stream-string-threading-cancellationtoken-officeimo-drawing-officeimageinfo)

[OfficeImageReader.cs:104](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeImageReader.cs#L104)

Validates a complete bounded image payload and observes cancellation while reading, parsing, and decoding the payload.

Parameters

**stream System.IO.Stream required**

**fileName string? required**

**cancellationToken System.Threading.CancellationToken required**

**info OfficeIMO.Drawing.OfficeImageInfo required**

Returns

`bool`

`public static bool TryValidateContent(byte[]? data, string? fileName, out OfficeImageInfo info)` [#](#method-tryvalidatecontent-byte-string-officeimo-drawing-officeimageinfo)

[OfficeImageReader.cs:196](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeImageReader.cs#L196)

Validates a complete bounded image payload and returns its metadata. Unlike metadata identification, this decodes supported PNG, JPEG, GIF, BMP, TIFF, WebP, and AVIF payloads and validates every ICO entry so structurally plausible but incomplete image bodies are rejected.

Parameters

**data byte[]? required**

**fileName string? required**

**info OfficeIMO.Drawing.OfficeImageInfo required**

Returns

`bool`

`public static bool TryValidateContent(byte[]? data, string? fileName, CancellationToken cancellationToken, out OfficeImageInfo info)` [#](#method-tryvalidatecontent-byte-string-threading-cancellationtoken-officeimo-drawing-officeimageinfo)

[OfficeImageReader.cs:207](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeImageReader.cs#L207)

Validates a complete bounded image payload and observes cancellation while parsing and decoding it.

Parameters

**data byte[]? required**

**fileName string? required**

**cancellationToken System.Threading.CancellationToken required**

**info OfficeIMO.Drawing.OfficeImageInfo required**

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:4C3269C44BCFDB950DBA072EDAAF303797166BEA01E957FA91449284B43A9BBE -->
