Clean up image import a bit
This commit is contained in:
parent
8c29b8fa85
commit
4a478b2442
@ -78,7 +78,7 @@ class ImageSpec extends TypeSpec {
|
|||||||
|
|
||||||
const processImportables = backgroundTask(async function _processImportables(image) {
|
const processImportables = backgroundTask(async function _processImportables(image) {
|
||||||
const { _id, _rev, sizes, digest } = image;
|
const { _id, _rev, sizes, digest } = image;
|
||||||
const imageData = await FileType.getFromURL(image.sizes.full);
|
const imageData = await FileType.getFromURL(sizes.full);
|
||||||
|
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
const imageProps = await new Promise(resolve => {
|
const imageProps = await new Promise(resolve => {
|
||||||
@ -93,19 +93,14 @@ const processImportables = backgroundTask(async function _processImportables(ima
|
|||||||
const ExifParser = await import('exif-parser');
|
const ExifParser = await import('exif-parser');
|
||||||
const buffer = await blobToArrayBuffer(imageData);
|
const buffer = await blobToArrayBuffer(imageData);
|
||||||
|
|
||||||
try {
|
|
||||||
const exifData = ExifParser.create(buffer).parse();
|
const exifData = ExifParser.create(buffer).parse();
|
||||||
const { tags } = exifData;
|
const { tags } = exifData;
|
||||||
const originalDate = new Date(
|
const originalDate = new Date(
|
||||||
tags.DateTimeOriginal
|
tags.DateTimeOriginal ? new Date(tags.DateTimeOriginal * 1000).toISOString() : image.originalDate
|
||||||
? new Date(tags.DateTimeOriginal * 1000).toISOString()
|
|
||||||
: image.originalDate
|
|
||||||
).toISOString();
|
).toISOString();
|
||||||
|
|
||||||
deepAssign(imageProps, {
|
deepAssign(imageProps, {
|
||||||
originalDate,
|
originalDate,
|
||||||
width,
|
|
||||||
height,
|
|
||||||
orientation: tags.Orientation,
|
orientation: tags.Orientation,
|
||||||
digest,
|
digest,
|
||||||
make: tags.Make,
|
make: tags.Make,
|
||||||
@ -120,9 +115,6 @@ const processImportables = backgroundTask(async function _processImportables(ima
|
|||||||
heading: tags.GPSImgDirection
|
heading: tags.GPSImgDirection
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
|
||||||
error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete image.importing;
|
delete image.importing;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user