# HtmlImageDataUri

Represents an image data URI split into media type, encoding metadata, and payload.

Class 

`OfficeIMO.Html`

**Namespace**

`OfficeIMO.Html`

**Assembly**

`OfficeIMO.Html`

**Source revision**

`be6c300e4ab1` with working tree changes

**Source**

[HtmlImageDataUri.cs:33](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Html/Images/HtmlImageDataUri.cs#L33)

**Modifiers**

sealed

Represents an image data URI split into media type, encoding metadata, and payload.

## Inheritance

- object
- HtmlImageDataUri

## Usage

Explore 1 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

### Accepted by parameters 1

- Method [HtmlImageDataUri.TryParse](/api/html/officeimo-html-htmlimagedatauri/#method-tryparse-string-officeimo-html-htmlimagedatauri) parameter `dataUri`

Filter members 

Show inherited

## Methods

`public byte[] DecodeBytes()` [#](#method-decodebytes)

[HtmlImageDataUri.cs:53](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Html/Images/HtmlImageDataUri.cs#L53)

Decodes the image payload as bytes.

Returns

`byte[]`

`public string DecodeText()` [#](#method-decodetext)

[HtmlImageDataUri.cs:59](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Html/Images/HtmlImageDataUri.cs#L59)

Decodes the payload using its declared charset, or UTF-8 when none is declared.

Returns

`string`

`public long EstimateDecodedByteCount()` [#](#method-estimatedecodedbytecount)

[HtmlImageDataUri.cs:65](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Html/Images/HtmlImageDataUri.cs#L65)

Estimates decoded byte count without allocating decoded content when possible.

Returns

`long`

`public static string GetFileExtension(string mediaType)` [#](#method-getfileextension-string)

[HtmlImageDataUri.cs:33](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Html/Images/HtmlImageDataUri.cs#L33)

Gets the suggested file extension for an image media type.

Parameters

**mediaType string required**

Returns

`string`

`public bool TryDecodeBytes(out byte[] bytes)` [#](#method-trydecodebytes-byte)

[HtmlImageDataUri.cs:56](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Html/Images/HtmlImageDataUri.cs#L56)

Attempts to decode the image payload as bytes.

Parameters

**bytes byte[] required**

Returns

`bool`

`public bool TryDecodeText(out string text)` [#](#method-trydecodetext-string)

[HtmlImageDataUri.cs:62](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Html/Images/HtmlImageDataUri.cs#L62)

Attempts to decode the payload using its declared charset, or UTF-8 when none is declared.

Parameters

**text string required**

Returns

`bool`

`public bool TryEstimateDecodedByteCount(out long byteCount)` [#](#method-tryestimatedecodedbytecount-int64)

[HtmlImageDataUri.cs:68](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Html/Images/HtmlImageDataUri.cs#L68)

Attempts to estimate decoded byte count without throwing for malformed payloads.

Parameters

**byteCount long required**

Returns

`bool`

`public static bool TryParse(string? source, out HtmlImageDataUri dataUri)` [#](#method-tryparse-string-officeimo-html-htmlimagedatauri)

[HtmlImageDataUri.cs:37](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Html/Images/HtmlImageDataUri.cs#L37)

Tries to parse an image data URI.

Parameters

**source string? required**

**dataUri OfficeIMO.Html.HtmlImageDataUri 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?`

## Properties

`public string Metadata { get; }` [#](#property-metadata)

[HtmlImageDataUri.cs:15](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Html/Images/HtmlImageDataUri.cs#L15)

Data URI metadata without the leading data: prefix.

`public string MediaType { get; }` [#](#property-mediatype)

[HtmlImageDataUri.cs:18](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Html/Images/HtmlImageDataUri.cs#L18)

Declared image media type, for example image/png.

`public string Data { get; }` [#](#property-data)

[HtmlImageDataUri.cs:21](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Html/Images/HtmlImageDataUri.cs#L21)

Raw payload after the comma separator.

`public bool IsBase64 { get; }` [#](#property-isbase64)

[HtmlImageDataUri.cs:24](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Html/Images/HtmlImageDataUri.cs#L24)

Indicates whether the payload is base64 encoded.

`public string Fragment { get; }` [#](#property-fragment)

[HtmlImageDataUri.cs:27](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Html/Images/HtmlImageDataUri.cs#L27)

URL fragment suffix, including the leading hash when present.

`public string FileExtension { get; }` [#](#property-fileextension)

[HtmlImageDataUri.cs:30](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Html/Images/HtmlImageDataUri.cs#L30)

Suggested file extension for the media type, including the leading dot.

<!-- PowerForge markdown artifact sha256:65FD3137ECB4BE241B0546D8F1A2FCF5F3C2ECB9CB4B180F26F1EC1DC20F27A4 -->
