diff --git a/src/display/editor/stamp.js b/src/display/editor/stamp.js index ab08dcf0c5172..a57b522f27b69 100644 --- a/src/display/editor/stamp.js +++ b/src/display/editor/stamp.js @@ -441,26 +441,22 @@ class StampEditor extends AnnotationEditor { width, height ); - offscreen.convertToBlob().then(blob => { - const fileReader = new FileReader(); - fileReader.onload = () => { - const url = fileReader.result; - this._uiManager - .mlGuess({ - service: "image-to-text", - request: { - imageData: url, - }, - }) - .then(response => { - const altText = response?.output || ""; - if (this.parent && altText && !this.hasAltText()) { - this.altTextData = { altText, decorative: false }; - } - }); - }; - fileReader.readAsDataURL(blob); - }); + this._uiManager + .mlGuess({ + service: "image-to-text", + request: { + data: ctx.getImageData(0, 0, width, height).data, + width, + height, + channels: 4, + }, + }) + .then(response => { + const altText = response?.output || ""; + if (this.parent && altText && !this.hasAltText()) { + this.altTextData = { altText, decorative: false }; + } + }); } const ctx = canvas.getContext("2d"); ctx.filter = this._uiManager.hcmFilter;