From a71a8e4d9697b6afeb371c5de331ee00d9a70261 Mon Sep 17 00:00:00 2001 From: abhinav-grd Date: Fri, 10 Sep 2021 12:50:21 +0530 Subject: [PATCH] updates exifInfo usage of exifParser --- src/components/PhotoSwipe/PhotoSwipe.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/PhotoSwipe/PhotoSwipe.tsx b/src/components/PhotoSwipe/PhotoSwipe.tsx index 09e97d5eb..729ab9dc3 100644 --- a/src/components/PhotoSwipe/PhotoSwipe.tsx +++ b/src/components/PhotoSwipe/PhotoSwipe.tsx @@ -10,7 +10,7 @@ import { import { File, FILE_TYPE } from 'services/fileService'; import constants from 'utils/strings/constants'; import DownloadManger from 'services/downloadManager'; -import EXIF from 'exif-js'; +import exifr from 'exifr'; import Modal from 'react-bootstrap/Modal'; import Button from 'react-bootstrap/Button'; import Form from 'react-bootstrap/Form'; @@ -263,16 +263,18 @@ function PhotoSwipe(props: Iprops) { const checkExifAvailable = () => { setExif(null); setTimeout(() => { - const img = document.querySelector( + const img: HTMLImageElement = document.querySelector( '.pswp__img:not(.pswp__img--placeholder)' ); if (img) { - // @ts-expect-error - EXIF.getData(img, function () { - const exif = EXIF.getAllTags(this); - exif.raw = EXIF.pretty(this); - if (exif.raw) { - setExif(exif); + exifr.parse(img).then(function (exifData) { + console.log(exifData); + if (!exifData) { + return; + } + exifData.raw = JSON.stringify(exifData, null, 2); + if (exifData) { + setExif(exifData); } }); }