Merge pull request #18136 from calixteman/ml_stamp

[Editor] Pass a buffer instead of a blob url to the ML api
This commit is contained in:
calixteman 2024-05-21 18:24:26 +02:00 committed by GitHub
commit 5da2894278
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -441,15 +441,14 @@ class StampEditor extends AnnotationEditor {
width, width,
height height
); );
offscreen.convertToBlob().then(blob => {
const fileReader = new FileReader();
fileReader.onload = () => {
const url = fileReader.result;
this._uiManager this._uiManager
.mlGuess({ .mlGuess({
service: "image-to-text", service: "image-to-text",
request: { request: {
imageData: url, data: ctx.getImageData(0, 0, width, height).data,
width,
height,
channels: 4,
}, },
}) })
.then(response => { .then(response => {
@ -458,9 +457,6 @@ class StampEditor extends AnnotationEditor {
this.altTextData = { altText, decorative: false }; this.altTextData = { altText, decorative: false };
} }
}); });
};
fileReader.readAsDataURL(blob);
});
} }
const ctx = canvas.getContext("2d"); const ctx = canvas.getContext("2d");
ctx.filter = this._uiManager.hcmFilter; ctx.filter = this._uiManager.hcmFilter;