OfficeImageReader
OfficeIMO.Drawing
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?
Returns
OfficeImageFormatpublic static OfficeImageInfo Identify(string filePath) #Identifies image metadata from a file.
Parameters
- filePath string
Returns
OfficeImageInfopublic static OfficeImageInfo Identify(byte[] data, string? fileName = null) #Identifies image metadata from a byte array.
Parameters
- data byte[]
- fileName string? = null
Returns
OfficeImageInfopublic 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?
- 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[]
- options OfficeIMO.Drawing.OfficeRasterDecodeOptions?
- info OfficeIMO.Drawing.OfficeImageInfo
Returns
byte[]Exceptions
NotSupportedException– The required system codec is unavailable or the HEIC profile is unsupported.
public static bool TryIdentify(Stream stream, string? fileName, out OfficeImageInfo info) #Tries to identify image metadata from a stream.
Parameters
- stream System.IO.Stream
- fileName string?
- info OfficeIMO.Drawing.OfficeImageInfo
Returns
boolpublic static bool TryIdentify(byte[]? data, string? fileName, out OfficeImageInfo info) #Tries to identify image metadata from a byte array.
Parameters
- data byte[]?
- fileName string?
- info OfficeIMO.Drawing.OfficeImageInfo
Returns
boolpublic 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
- fileName string?
- info OfficeIMO.Drawing.OfficeImageInfo
Returns
boolpublic 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[]?
- fileName string?
- info OfficeIMO.Drawing.OfficeImageInfo
Returns
boolpublic 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?
- maximumImageBytes long
- bytes byte[]
- info OfficeIMO.Drawing.OfficeImageInfo
Returns
boolpublic 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
- fileName string?
- info OfficeIMO.Drawing.OfficeImageInfo
Returns
boolpublic 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
- fileName string?
- cancellationToken System.Threading.CancellationToken
- info OfficeIMO.Drawing.OfficeImageInfo
Returns
boolpublic 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[]?
- fileName string?
- info OfficeIMO.Drawing.OfficeImageInfo
Returns
boolpublic 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[]?
- fileName string?
- cancellationToken System.Threading.CancellationToken
- info OfficeIMO.Drawing.OfficeImageInfo
Returns
bool