From 4aa9872c949831215c31fe4a076503ddd6895521 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 12 Sep 2021 11:40:03 -0500 Subject: [PATCH] Load exif.js library asynchronously --- app/soapbox/utils/resize_image.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/soapbox/utils/resize_image.js b/app/soapbox/utils/resize_image.js index ffb4ef936..26bb36c76 100644 --- a/app/soapbox/utils/resize_image.js +++ b/app/soapbox/utils/resize_image.js @@ -1,6 +1,4 @@ /* eslint-disable no-case-declarations */ -import EXIF from 'exif-js'; - const MAX_IMAGE_PIXELS = 2073600; // 1920x1080px const _browser_quirks = {}; @@ -115,14 +113,16 @@ const getOrientation = (img, type = 'image/png') => new Promise(resolve => { return; } - EXIF.getData(img, () => { - const orientation = EXIF.getTag(img, 'Orientation'); - if (orientation !== 1) { - dropOrientationIfNeeded(orientation).then(resolve).catch(() => resolve(orientation)); - } else { - resolve(orientation); - } - }); + import(/* webpackChunkName: "features/compose" */'exif-js').then(({ default: EXIF }) => { + EXIF.getData(img, () => { + const orientation = EXIF.getTag(img, 'Orientation'); + if (orientation !== 1) { + dropOrientationIfNeeded(orientation).then(resolve).catch(() => resolve(orientation)); + } else { + resolve(orientation); + } + }); + }).catch(() => {}); }); const processImage = (img, { width, height, orientation, type = 'image/png', name = 'resized.png' }) => new Promise(resolve => {