Merge branch 'exif-async' into 'develop'

Load exif.js library asynchronously

See merge request soapbox-pub/soapbox-fe!748
This commit is contained in:
Alex Gleason 2021-09-12 16:56:39 +00:00
commit 726d13e989
1 changed files with 10 additions and 10 deletions

View File

@ -1,6 +1,4 @@
/* eslint-disable no-case-declarations */ /* eslint-disable no-case-declarations */
import EXIF from 'exif-js';
const MAX_IMAGE_PIXELS = 2073600; // 1920x1080px const MAX_IMAGE_PIXELS = 2073600; // 1920x1080px
const _browser_quirks = {}; const _browser_quirks = {};
@ -115,6 +113,7 @@ const getOrientation = (img, type = 'image/png') => new Promise(resolve => {
return; return;
} }
import(/* webpackChunkName: "features/compose" */'exif-js').then(({ default: EXIF }) => {
EXIF.getData(img, () => { EXIF.getData(img, () => {
const orientation = EXIF.getTag(img, 'Orientation'); const orientation = EXIF.getTag(img, 'Orientation');
if (orientation !== 1) { if (orientation !== 1) {
@ -123,6 +122,7 @@ const getOrientation = (img, type = 'image/png') => new Promise(resolve => {
resolve(orientation); resolve(orientation);
} }
}); });
}).catch(() => {});
}); });
const processImage = (img, { width, height, orientation, type = 'image/png', name = 'resized.png' }) => new Promise(resolve => { const processImage = (img, { width, height, orientation, type = 'image/png', name = 'resized.png' }) => new Promise(resolve => {