mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
fix(server): better metadata extraction for images (#2653)
This commit is contained in:
parent
cab5477656
commit
f9b1d1edaf
10 changed files with 215 additions and 63 deletions
46
server/apps/microservices/src/utils/exif/coordinates.spec.ts
Normal file
46
server/apps/microservices/src/utils/exif/coordinates.spec.ts
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import { describe, it, expect } from '@jest/globals';
|
||||
import { parseLatitude, parseLongitude } from './coordinates';
|
||||
|
||||
describe('parsing latitude from string input', () => {
|
||||
it('returns null for invalid inputs', () => {
|
||||
expect(parseLatitude('')).toBeNull();
|
||||
expect(parseLatitude('NaN')).toBeNull();
|
||||
expect(parseLatitude('Infinity')).toBeNull();
|
||||
expect(parseLatitude('-Infinity')).toBeNull();
|
||||
expect(parseLatitude('90.001')).toBeNull();
|
||||
expect(parseLatitude(-90.000001)).toBeNull();
|
||||
expect(parseLatitude('1000')).toBeNull();
|
||||
expect(parseLatitude(-1000)).toBeNull();
|
||||
});
|
||||
|
||||
it('returns the numeric coordinate for valid inputs', () => {
|
||||
expect(parseLatitude('90')).toBeCloseTo(90);
|
||||
expect(parseLatitude('-90')).toBeCloseTo(-90);
|
||||
expect(parseLatitude(89.999999)).toBeCloseTo(89.999999);
|
||||
expect(parseLatitude('-89.9')).toBeCloseTo(-89.9);
|
||||
expect(parseLatitude(0)).toBeCloseTo(0);
|
||||
expect(parseLatitude('-0.0')).toBeCloseTo(-0.0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('parsing longitude from string input', () => {
|
||||
it('returns null for invalid inputs', () => {
|
||||
expect(parseLongitude('')).toBeNull();
|
||||
expect(parseLongitude('NaN')).toBeNull();
|
||||
expect(parseLongitude(Infinity)).toBeNull();
|
||||
expect(parseLongitude('-Infinity')).toBeNull();
|
||||
expect(parseLongitude('180.001')).toBeNull();
|
||||
expect(parseLongitude('-180.000001')).toBeNull();
|
||||
expect(parseLongitude(1000)).toBeNull();
|
||||
expect(parseLongitude('-1000')).toBeNull();
|
||||
});
|
||||
|
||||
it('returns the numeric coordinate for valid inputs', () => {
|
||||
expect(parseLongitude(180)).toBeCloseTo(180);
|
||||
expect(parseLongitude('-180')).toBeCloseTo(-180);
|
||||
expect(parseLongitude('179.999999')).toBeCloseTo(179.999999);
|
||||
expect(parseLongitude(-179.9)).toBeCloseTo(-179.9);
|
||||
expect(parseLongitude('0')).toBeCloseTo(0);
|
||||
expect(parseLongitude('-0.0')).toBeCloseTo(-0.0);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue