extractAndEmbedBase64Images(filePath, [propertyFilter]) Last updated: 11. Apr 2025
API only function
This function extracts images encoded in base64 from HTML properties of a document. It then converts these images to a more storage-efficient format by saving them as embedded files within the document. The revised HTML will reference these images using a Content ID (CID) mechanism, similar to how images are referenced in email attachments.
Parameters
Name | Type | Description |
---|---|---|
filePath | string | The absolute path to the document where images will be extracted and embedded. |
propertyFilter (optional) | string | Specifies which properties to scan for base64 images. Use "*" (default) to scan all properties, or provide a specific property name. The function recursively searches through objects and arrays to find matching properties. Supports wildcards.RetryClaude can make mistakes. Please double-check responses. |
Returns
A number indicating the total count of base64 image references that were successfully extracted and updated to CID format in the document.
Example
Code example (JS)
JS is normal JavaScript either running in the browser or on the Docly™ server.let result = docly.extractAndEmbedBase64Images(fileToUpdate);
return extract;