From 5bad2e68ce5b47668bda3d0a8c0368803e1f730a Mon Sep 17 00:00:00 2001 From: Jerome Wu Date: Tue, 15 Sep 2020 12:39:41 +0800 Subject: [PATCH] Fix exif issue for base64 images --- src/worker/browser/loadImage.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/worker/browser/loadImage.js b/src/worker/browser/loadImage.js index b1cc14f..b9d9e12 100644 --- a/src/worker/browser/loadImage.js +++ b/src/worker/browser/loadImage.js @@ -48,17 +48,17 @@ const loadImage = async (image) => { } if (typeof image === 'string') { - // Base64 Image - if (/data:image\/([a-zA-Z]*);base64,([^"]*)/.test(image)) { - data = atob(image.split(',')[1]) - .split('') - .map(c => c.charCodeAt(0)); - } else if (image.endsWith('.pbm')) { + if (image.endsWith('.pbm')) { const resp = await fetch(resolveURL(image)); data = await resp.arrayBuffer(); } else { + let img = image; + // If not Base64 Image + if (!/data:image\/([a-zA-Z]*);base64,([^"]*)/.test(image)) { + img = resolveURL(image); + } data = await readFromBlobOrFile( - await fixOrientationFromUrlOrBlobOrFile(resolveURL(image)), + await fixOrientationFromUrlOrBlobOrFile(img), ); } } else if (image instanceof HTMLElement) {