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:
commit
5da2894278
@ -441,26 +441,22 @@ class StampEditor extends AnnotationEditor {
|
|||||||
width,
|
width,
|
||||||
height
|
height
|
||||||
);
|
);
|
||||||
offscreen.convertToBlob().then(blob => {
|
this._uiManager
|
||||||
const fileReader = new FileReader();
|
.mlGuess({
|
||||||
fileReader.onload = () => {
|
service: "image-to-text",
|
||||||
const url = fileReader.result;
|
request: {
|
||||||
this._uiManager
|
data: ctx.getImageData(0, 0, width, height).data,
|
||||||
.mlGuess({
|
width,
|
||||||
service: "image-to-text",
|
height,
|
||||||
request: {
|
channels: 4,
|
||||||
imageData: url,
|
},
|
||||||
},
|
})
|
||||||
})
|
.then(response => {
|
||||||
.then(response => {
|
const altText = response?.output || "";
|
||||||
const altText = response?.output || "";
|
if (this.parent && altText && !this.hasAltText()) {
|
||||||
if (this.parent && altText && !this.hasAltText()) {
|
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;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user