From 7c533280011a126d7a9cec4f76206c7f00477cf8 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Mon, 8 Aug 2022 18:00:51 -0700 Subject: [PATCH] im stuff --- packages/client/src/components/media-caption.vue | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/client/src/components/media-caption.vue b/packages/client/src/components/media-caption.vue index a528b6191..7d6ac36b4 100644 --- a/packages/client/src/components/media-caption.vue +++ b/packages/client/src/components/media-caption.vue @@ -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 } }) => {