mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 04:06:26 -04:00
Merge 7abe36f82007dc0128bc758c3f5a5c401c0e6205 into 63437529e1224f5e7879ce567b1a4502fb97573b
This commit is contained in:
commit
3f190908d7
@ -1,4 +1,5 @@
|
|||||||
import { BinaryField, ExifDateTime } from 'exiftool-vendored';
|
import { BinaryField, ExifDateTime } from 'exiftool-vendored';
|
||||||
|
import { DateTime } from 'luxon';
|
||||||
import { randomBytes } from 'node:crypto';
|
import { randomBytes } from 'node:crypto';
|
||||||
import { Stats } from 'node:fs';
|
import { Stats } from 'node:fs';
|
||||||
import { constants } from 'node:fs/promises';
|
import { constants } from 'node:fs/promises';
|
||||||
@ -871,10 +872,30 @@ describe(MetadataService.name, () => {
|
|||||||
metadataMock.readTags.mockResolvedValue(tags);
|
metadataMock.readTags.mockResolvedValue(tags);
|
||||||
|
|
||||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||||
expect(assetMock.getByIds).toHaveBeenCalledWith([assetStub.image.id]);
|
|
||||||
expect(assetMock.upsertExif).toHaveBeenCalledWith(
|
expect(assetMock.upsertExif).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
timeZone: 'UTC+0',
|
timeZone: 'UTC+0',
|
||||||
|
dateTimeOriginal: DateTime.fromISO('2024-09-01T00:00:00.000Z').toJSDate(),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should extract +00:00 timezone from raw value despite conflicting GPS location/timezone', async () => {
|
||||||
|
// exiftool-vendored returns a timezone derived from GPS coordinates even though "+00:00" might be set explicitly
|
||||||
|
// https://github.com/photostructure/exiftool-vendored.js/issues/203
|
||||||
|
|
||||||
|
const tags: ImmichTags = {
|
||||||
|
DateTimeOriginal: ExifDateTime.fromISO('2024-09-15T00:00:00.000+00:00'),
|
||||||
|
tz: 'America/Santiago',
|
||||||
|
};
|
||||||
|
assetMock.getByIds.mockResolvedValue([assetStub.image]);
|
||||||
|
metadataMock.readTags.mockResolvedValue(tags);
|
||||||
|
|
||||||
|
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||||
|
expect(assetMock.upsertExif).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
timeZone: 'UTC+0',
|
||||||
|
dateTimeOriginal: DateTime.fromISO('2024-09-15T00:00:00.000Z').toJSDate(),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -623,12 +623,10 @@ export class MetadataService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// timezone
|
// timezone
|
||||||
let timeZone = exifTags.tz ?? null;
|
// exiftool-vendored returns "no timezone" information or one derived from GPS coordinates even though "+00:00"
|
||||||
if (timeZone == null && dateTime?.rawValue?.endsWith('+00:00')) {
|
// might be set explicitly
|
||||||
// exiftool-vendored returns "no timezone" information even though "+00:00" might be set explicitly
|
// https://github.com/photostructure/exiftool-vendored.js/issues/203
|
||||||
// https://github.com/photostructure/exiftool-vendored.js/issues/203
|
const timeZone = dateTime?.rawValue?.endsWith('+00:00') ? 'UTC+0' : (exifTags.tz ?? null);
|
||||||
timeZone = 'UTC+0';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (timeZone) {
|
if (timeZone) {
|
||||||
this.logger.debug(`Asset ${asset.id} timezone is ${timeZone} (via ${exifTags.tzSource})`);
|
this.logger.debug(`Asset ${asset.id} timezone is ${timeZone} (via ${exifTags.tzSource})`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user