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,36 +93,28 @@ 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 ? new Date(tags.DateTimeOriginal * 1000).toISOString() : image.originalDate
|
||||||
tags.DateTimeOriginal
|
).toISOString();
|
||||||
? new Date(tags.DateTimeOriginal * 1000).toISOString()
|
|
||||||
: image.originalDate
|
|
||||||
).toISOString();
|
|
||||||
|
|
||||||
deepAssign(imageProps, {
|
deepAssign(imageProps, {
|
||||||
originalDate,
|
originalDate,
|
||||||
width,
|
orientation: tags.Orientation,
|
||||||
height,
|
digest,
|
||||||
orientation: tags.Orientation,
|
make: tags.Make,
|
||||||
digest,
|
model: tags.Model,
|
||||||
make: tags.Make,
|
flash: !!tags.Flash,
|
||||||
model: tags.Model,
|
iso: tags.ISO,
|
||||||
flash: !!tags.Flash,
|
sizes,
|
||||||
iso: tags.ISO,
|
gps: {
|
||||||
sizes,
|
latitude: tags.GPSLatitude,
|
||||||
gps: {
|
longitude: tags.GPSLongitude,
|
||||||
latitude: tags.GPSLatitude,
|
altitude: tags.GPSAltitude,
|
||||||
longitude: tags.GPSLongitude,
|
heading: tags.GPSImgDirection
|
||||||
altitude: tags.GPSAltitude,
|
}
|
||||||
heading: tags.GPSImgDirection
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete image.importing;
|
delete image.importing;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user