You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
710 B
35 lines
710 B
import { Injectable } from '@angular/core';
|
|
import * as exifr from 'exifr';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class ExifService {
|
|
async getOrientation(file: File): Promise<number | undefined> {
|
|
try {
|
|
return await exifr.orientation(file);
|
|
} catch (error) {
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
async getLocation(
|
|
file: File
|
|
): Promise<{ latitude?: number; longitude?: number }> {
|
|
try {
|
|
return exifr.gps(file);
|
|
} catch (error) {
|
|
return {};
|
|
}
|
|
}
|
|
|
|
async getDateTime(file: File): Promise<string> {
|
|
try {
|
|
const data = await exifr.parse(file);
|
|
return data.DateTimeOriginal.toISOString();
|
|
} catch (error) {
|
|
return '';
|
|
}
|
|
}
|
|
}
|