remove exif file check and let exif library handle it and fail
This commit is contained in:
parent
e059f16325
commit
7539f5c9fa
|
@ -5,7 +5,6 @@ import { NULL_LOCATION, Location } from './metadataService';
|
|||
|
||||
const SOUTH_DIRECTION = 'S';
|
||||
const WEST_DIRECTION = 'W';
|
||||
const EXIF_HAVING_TYPES = new Set(['jpeg', 'jpg', 'tiff']);
|
||||
const CHUNK_SIZE_FOR_EXIF_READING = 4 * 1024 * 1024;
|
||||
interface ParsedEXIFData {
|
||||
location: Location;
|
||||
|
@ -14,14 +13,9 @@ interface ParsedEXIFData {
|
|||
|
||||
export async function getExifData(
|
||||
worker,
|
||||
receivedFile: globalThis.File,
|
||||
exactType: string
|
||||
receivedFile: globalThis.File
|
||||
): Promise<ParsedEXIFData> {
|
||||
try {
|
||||
if (!fileHasEXIF(exactType)) {
|
||||
// files don't have exif
|
||||
return { location: NULL_LOCATION, creationTime: null };
|
||||
}
|
||||
const fileChunk = await worker.getUint8ArrayView(
|
||||
receivedFile.slice(0, CHUNK_SIZE_FOR_EXIF_READING)
|
||||
);
|
||||
|
@ -39,10 +33,6 @@ export async function getExifData(
|
|||
}
|
||||
}
|
||||
|
||||
function fileHasEXIF(type) {
|
||||
return EXIF_HAVING_TYPES.has(type);
|
||||
}
|
||||
|
||||
function getUNIXTime(exifData: any) {
|
||||
const dateString: string = exifData.DateTimeOriginal || exifData.DateTime;
|
||||
if (!dateString || dateString === '0000:00:00 00:00:00') {
|
||||
|
|
|
@ -32,11 +32,7 @@ export async function extractMetadata(
|
|||
receivedFile: globalThis.File,
|
||||
fileTypeInfo: FileTypeInfo
|
||||
) {
|
||||
const { location, creationTime } = await getExifData(
|
||||
worker,
|
||||
receivedFile,
|
||||
fileTypeInfo.exactType
|
||||
);
|
||||
const { location, creationTime } = await getExifData(worker, receivedFile);
|
||||
|
||||
const extractedMetadata: MetadataObject = {
|
||||
title: receivedFile.name,
|
||||
|
|
Loading…
Reference in a new issue