Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

OfficeImageReader

OfficeIMO.Drawing

Namespace
OfficeIMO.Drawing
Assembly
OfficeIMO.Core
Source revision
ba882f6b0d07 with working tree changes
Modifiers
static

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

Inheritance

  • object
  • OfficeImageReader

Methods

public static OfficeImageFormat FromExtension(string? fileName) #

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

Parameters

fileName string? required
Identify 2 overloads
public static OfficeImageInfo Identify(string filePath) #

Identifies image metadata from a file.

Parameters

filePath string required
public static OfficeImageInfo Identify(byte[] data, string? fileName = null) #

Identifies image metadata from a byte array.

Parameters

data byte[] required
fileName string? = null optional
public static bool IsKnownImageExtension(string? fileName) #

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

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

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

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

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

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

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

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

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

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

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