From 20dda846ccfa12789c33e62c4bad58ce7841955d Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 28 May 2023 19:05:20 +0100 Subject: Update docs for reading images --- README.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 8512ffe..cb3d937 100644 --- a/README.md +++ b/README.md @@ -479,11 +479,19 @@ This creates an `` element for each image in the original docx. This argument is the image element being converted, and has the following properties: -* `read([encoding])`: read the image file with the specified encoding. - If no encoding is specified, a `Buffer` is returned. - * `contentType`: the content type of the image, such as `image/png`. +* `readAsArrayBuffer()`: read the image file as an `ArrayBuffer`. + +* `readAsBuffer()`: read the image file as a `Buffer`. + This is not supported in browsers unless a `Buffer` polyfill has been used. + +* `readAsBase64String()`: read the image file as a base64-encoded string. + +* `read([encoding])` (deprecated): read the image file with the specified encoding. + If an encoding is specified, a `string` is returned. + If no encoding is specified, a `Buffer` is returned. + `func` should return an object (or a promise of an object) of attributes for the `` element. At a minimum, this should include the `src` attribute. If any alt text is found for the image, @@ -493,7 +501,7 @@ For instance, the following replicates the default image conversion: ```javascript mammoth.images.imgElement(function(image) { - return image.read("base64").then(function(imageBuffer) { + return image.readAsBase64String().then(function(imageBuffer) { return { src: "data:" + image.contentType + ";base64," + imageBuffer }; -- cgit v1.2.3