aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-05-28 19:05:20 +0100
committerMichael Williamson <mike@zwobble.org>2023-05-28 19:05:20 +0100
commit20dda846ccfa12789c33e62c4bad58ce7841955d (patch)
treeaca28f2d0877556a8d87b4d54f1db41415127aae /README.md
parent82f8d243b6aba94bd9ed083f242f2470e00fc122 (diff)
Update docs for reading images
Diffstat (limited to 'README.md')
-rw-r--r--README.md16
1 files changed, 12 insertions, 4 deletions
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 `<img>` 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 `<img>` 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
};