This commit is contained in:
ThatOneCalculator 2022-08-08 18:00:51 -07:00
parent 58ff242241
commit 7c53328001

View file

@ -141,9 +141,21 @@ export default defineComponent({
},
caption() {
const img = document.getElementById('imgtocaption');
const getBase64FromUrl = async (url) => {
const data = await fetch(url);
const blob = await data.blob();
return new Promise((resolve) => {
const reader = new FileReader();
reader.readAsDataURL(blob);
reader.onloadend = () => {
const base64data = reader.result;
resolve(base64data);
};
});
};
const img = document.getElementById('imgtocaption') as HTMLImageElement;
Tesseract.recognize(
img,
getBase64FromUrl(img.src),
'eng',
{ logger: m => console.log(m) },
).then(({ data: { text } }) => {