Using image-js to generate images thumbnails (doesn't work well because of the lack of advanced interpolation methods in the current version)

This commit is contained in:
Eric van der Vlist 2023-04-18 17:45:48 +02:00
parent 15984a0d5d
commit ee980f219b
1 changed files with 9 additions and 2 deletions

View File

@ -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<Props> = ({ 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,