HtmlForgeX

API Reference

Class

ImageEmbedding

Namespace HtmlForgeX
Assembly HtmlForgeX
Modifiers static

Shared utility for image embedding functionality Used by both EmailImage and TablerCardImage to avoid code duplication

Inheritance

  • Object
  • ImageEmbedding

Methods

public static ImageEmbeddingResult EmbedFromFile(String filePath, Int64 maxFileSize = 0, Boolean logWarnings = false, Boolean optimize = false, Int32 maxWidth = 0, Int32 maxHeight = 0, Int32 quality = 85) #
Returns: ImageEmbeddingResult

Embeds an image from a file path as base64

Parameters

filePath System.String requiredposition: 0
Path to the image file
maxFileSize System.Int64 = 0 optionalposition: 1
Maximum file size allowed for embedding (0 = no limit)
logWarnings System.Boolean = false optionalposition: 2
Whether to log warnings to console
optimize System.Boolean = false optionalposition: 3
Whether to optimize the image before encoding
maxWidth System.Int32 = 0 optionalposition: 4
Maximum width used when optimizing
maxHeight System.Int32 = 0 optionalposition: 5
Maximum height used when optimizing
quality System.Int32 = 85 optionalposition: 6
JPEG quality used for optimization

Returns

ImageEmbeddingResult containing the embedding data or error info

public static ImageEmbeddingResult EmbedFromUrl(String url, Int32 timeoutSeconds = 30, Int64 maxFileSize = 0, Boolean logWarnings = false, Boolean optimize = false, Int32 maxWidth = 0, Int32 maxHeight = 0, Int32 quality = 85) #
Returns: ImageEmbeddingResult

Embeds an image from a URL as base64

Parameters

url System.String requiredposition: 0
URL to download and embed
timeoutSeconds System.Int32 = 30 optionalposition: 1
Timeout for the download
maxFileSize System.Int64 = 0 optionalposition: 2
Maximum file size allowed for embedding (0 = no limit)
logWarnings System.Boolean = false optionalposition: 3
Whether to log warnings to console
optimize System.Boolean = false optionalposition: 4
Whether to optimize the image before encoding
maxWidth System.Int32 = 0 optionalposition: 5
Maximum width used when optimizing
maxHeight System.Int32 = 0 optionalposition: 6
Maximum height used when optimizing
quality System.Int32 = 85 optionalposition: 7
JPEG quality used for optimization

Returns

ImageEmbeddingResult containing the embedding data or error info

public static async Task<ImageEmbeddingResult> EmbedFromUrlAsync(String url, Int32 timeoutSeconds = 30, Int64 maxFileSize = 0, Boolean logWarnings = false, Boolean optimize = false, Int32 maxWidth = 0, Int32 maxHeight = 0, Int32 quality = 85) #
Returns: Task<ImageEmbeddingResult>

Asynchronously embeds an image from a URL as base64

Parameters

url System.String requiredposition: 0
URL to download and embed
timeoutSeconds System.Int32 = 30 optionalposition: 1
Timeout for the download
maxFileSize System.Int64 = 0 optionalposition: 2
Maximum file size allowed for embedding (0 = no limit)
logWarnings System.Boolean = false optionalposition: 3
Whether to log warnings to console
optimize System.Boolean = false optionalposition: 4
Whether to optimize the image before encoding
maxWidth System.Int32 = 0 optionalposition: 5
Maximum width used when optimizing
maxHeight System.Int32 = 0 optionalposition: 6
Maximum height used when optimizing
quality System.Int32 = 85 optionalposition: 7
JPEG quality used for optimization

Returns

ImageEmbeddingResult containing the embedding data or error info

public static ImageEmbeddingResult EmbedSmart(String source, Int32 timeoutSeconds = 30, Int64 maxFileSize = 0, Boolean logWarnings = false, Boolean optimize = false, Int32 maxWidth = 0, Int32 maxHeight = 0, Int32 quality = 85) #
Returns: ImageEmbeddingResult

Smart embedding - auto-detects whether source is a file path or URL

Parameters

source System.String requiredposition: 0
File path or URL
timeoutSeconds System.Int32 = 30 optionalposition: 1
Timeout for URL downloads
maxFileSize System.Int64 = 0 optionalposition: 2
Maximum file size allowed for embedding (0 = no limit)
logWarnings System.Boolean = false optionalposition: 3
Whether to log warnings to console
optimize System.Boolean = false optionalposition: 4
Whether to optimize the image before encoding
maxWidth System.Int32 = 0 optionalposition: 5
Maximum width used when optimizing
maxHeight System.Int32 = 0 optionalposition: 6
Maximum height used when optimizing
quality System.Int32 = 85 optionalposition: 7
JPEG quality used for optimization

Returns

ImageEmbeddingResult containing the embedding data or error info

public static String GetMimeTypeFromExtension(String extension, String filePath = "") #
Returns: String

Gets MIME type from file extension

Parameters

extension System.String requiredposition: 0
File extension (with or without dot).
filePath System.String = "" optionalposition: 1
Optional file path used for context.

Returns

MIME type string

public static String GetMimeTypeFromUrl(String url) #
Returns: String

Gets MIME type from URL by examining the file extension

Parameters

url System.String requiredposition: 0
URL to examine

Returns

MIME type string