Fix: attempt to workaround for #2202

This commit is contained in:
Pieter Vander Vennet 2024-10-10 23:02:12 +02:00
parent 1b3687830c
commit 66465fdc98
2 changed files with 19 additions and 7 deletions

View file

@ -23,11 +23,14 @@ export default class PanoramaxImageProvider extends ImageProvider {
private static knownMeta: Record<string, { data: ImageData, time: Date }> = {} private static knownMeta: Record<string, { data: ImageData, time: Date }> = {}
public SourceIcon(img?: { id: string, url: string, host?: string }, location?: { lon: number; lat: number; }): BaseUIElement { public SourceIcon(img?: { id: string, url: string, host?: string }, location?: {
lon: number;
lat: number;
}): BaseUIElement {
const p = new Panoramax(img.host) const p = new Panoramax(img.host)
return new Link(new SvelteUIElement(Panoramax_bw), p.createViewLink({ return new Link(new SvelteUIElement(Panoramax_bw), p.createViewLink({
imageId: img?.id, imageId: img?.id,
location location,
}), true) }), true)
} }
@ -173,15 +176,24 @@ export class PanoramaxUploader implements ImageUploader {
absoluteUrl: string absoluteUrl: string
}> { }> {
let tags: ExifReader.Tags = undefined
let hasDate = false
let hasGPS = false
try {
const tags = await ExifReader.load(blob) const tags = await ExifReader.load(blob)
const hasDate = tags.DateTime !== undefined hasDate = tags?.DateTime !== undefined
const hasGPS = tags.GPSLatitude !== undefined && tags.GPSLongitude !== undefined hasGPS = tags?.GPSLatitude !== undefined && tags?.GPSLongitude !== undefined
} catch (e) {
console.error("Could not read EXIF-tags")
}
const [lon, lat] = currentGps let [lon, lat] = currentGps
const p = this._panoramax const p = this._panoramax
const defaultSequence = (await p.mySequences())[0] const defaultSequence = (await p.mySequences())[0]
const img = <ImageData>await p.addImage(blob, defaultSequence, { const img = <ImageData>await p.addImage(blob, defaultSequence, {
// It might seem odd that we set 'undefined' here - keep in mind that, by default, panoramax will use the EXIF-data
// We only pass variables as fallback!
lat: !hasGPS ? lat : undefined, lat: !hasGPS ? lat : undefined,
lon: !hasGPS ? lon : undefined, lon: !hasGPS ? lon : undefined,
datetime: !hasDate ? new Date().toISOString() : undefined, datetime: !hasDate ? new Date().toISOString() : undefined,