
NOTICE: All information contained herein is, and remains
the property of TechnoCore.
The intellectual and technical concepts contained
herein are proprietary to TechnoCore and dissemination of this information or reproduction of this material
is strictly forbidden unless prior written permission is obtained
from TechnoCore.
The ObjTextDataimage object is a utility for embedding an image directly into an HTML <img> tag using a data URI. This is useful for displaying images that are generated on the fly or stored in a database, as it avoids the need to save the image as a file.
The object constructs the <img> tag with the source (src) attribute populated with the Base64-encoded image data.
Process(Param1: str, Param2: str, Param3: str, Param4: str, ...)This method takes the necessary components of a data URI and constructs the complete <img> tag.
Parameters:
Param1 (str): The MIME type of the image (e.g., image/png, image/jpeg, image/svg+xml).Param2 (str): The Base64-encoded string of the image data.Param3 (str, optional): The alternative text (alt) for the image. Defaults to "Embedded Image".Param4 (str, optional): The CSS class to apply to the image. Defaults to img-fluid.Returns:
<img> tag with the embedded image.Example Usage:
# A simple 1x1 red pixel PNG, Base64 encoded
base64_red_pixel = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/wcAAwAB/epv2AAAAABJRU5ErkJggg=="
image_generator = ObjProcessText()
image_html = image_generator.Process(
Param1="image/png",
Param2=base64_red_pixel,
Param3="A single red pixel",
Param4="img-thumbnail"
)
print(image_html)
This would output:
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/wcAAwAB/epv2AAAAABJRU5ErkJggg==" class="img-thumbnail" alt="A single red pixel">