From ee980f219bf492c50b7826b65ecc3ffa4c16e47a Mon Sep 17 00:00:00 2001 From: evlist Date: Tue, 18 Apr 2023 17:45:48 +0200 Subject: [PATCH] Using image-js to generate images thumbnails (doesn't work well because of the lack of advanced interpolation methods in the current version) --- src/components/import/ImportSingleFile.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/import/ImportSingleFile.tsx b/src/components/import/ImportSingleFile.tsx index 6459b84..8ed6973 100644 --- a/src/components/import/ImportSingleFile.tsx +++ b/src/components/import/ImportSingleFile.tsx @@ -20,6 +20,7 @@ import { Encoding, } from '@capacitor/filesystem'; import ExifReader from 'exifreader'; +import { Image } from 'image-js'; interface Props { file: File; @@ -114,8 +115,14 @@ const ImportSingleFile: Component = ({ file: file }) => { }`; const id = exif?.ImageUniqueID?.value[0]; const gps = tags.gps; - const thumbnail = tags.Thumbnail; - const thumbnailUrl = `data:${thumbnail?.type};base64,${thumbnail?.base64}`; + const image = await Image.load(reader.result); + const thumbnail = image.resize({ + width: 256, + interpolation: 'bilinear', + }); + const thumbnailUrl = thumbnail.toDataURL(); + // const thumbnail = tags.Thumbnail; + //const thumbnailUrl = `data:${thumbnail?.type};base64,${thumbnail?.base64}`; console.log({ caller: 'ImportSingleFile / Jpeg', file,