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 SOUTH_DIRECTION = 'S';
|
||||||
const WEST_DIRECTION = 'W';
|
const WEST_DIRECTION = 'W';
|
||||||
const EXIF_HAVING_TYPES = new Set(['jpeg', 'jpg', 'tiff']);
|
|
||||||
const CHUNK_SIZE_FOR_EXIF_READING = 4 * 1024 * 1024;
|
const CHUNK_SIZE_FOR_EXIF_READING = 4 * 1024 * 1024;
|
||||||
interface ParsedEXIFData {
|
interface ParsedEXIFData {
|
||||||
location: Location;
|
location: Location;
|
||||||
|
@ -14,14 +13,9 @@ interface ParsedEXIFData {
|
||||||
|
|
||||||
export async function getExifData(
|
export async function getExifData(
|
||||||
worker,
|
worker,
|
||||||
receivedFile: globalThis.File,
|
receivedFile: globalThis.File
|
||||||
exactType: string
|
|
||||||
): Promise<ParsedEXIFData> {
|
): Promise<ParsedEXIFData> {
|
||||||
try {
|
try {
|
||||||
if (!fileHasEXIF(exactType)) {
|
|
||||||
// files don't have exif
|
|
||||||
return { location: NULL_LOCATION, creationTime: null };
|
|
||||||
}
|
|
||||||
const fileChunk = await worker.getUint8ArrayView(
|
const fileChunk = await worker.getUint8ArrayView(
|
||||||
receivedFile.slice(0, CHUNK_SIZE_FOR_EXIF_READING)
|
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) {
|
function getUNIXTime(exifData: any) {
|
||||||
const dateString: string = exifData.DateTimeOriginal || exifData.DateTime;
|
const dateString: string = exifData.DateTimeOriginal || exifData.DateTime;
|
||||||
if (!dateString || dateString === '0000:00:00 00:00:00') {
|
if (!dateString || dateString === '0000:00:00 00:00:00') {
|
||||||
|
|
|
@ -32,11 +32,7 @@ export async function extractMetadata(
|
||||||
receivedFile: globalThis.File,
|
receivedFile: globalThis.File,
|
||||||
fileTypeInfo: FileTypeInfo
|
fileTypeInfo: FileTypeInfo
|
||||||
) {
|
) {
|
||||||
const { location, creationTime } = await getExifData(
|
const { location, creationTime } = await getExifData(worker, receivedFile);
|
||||||
worker,
|
|
||||||
receivedFile,
|
|
||||||
fileTypeInfo.exactType
|
|
||||||
);
|
|
||||||
|
|
||||||
const extractedMetadata: MetadataObject = {
|
const extractedMetadata: MetadataObject = {
|
||||||
title: receivedFile.name,
|
title: receivedFile.name,
|
||||||
|
|
Loading…
Reference in a new issue