Read GPSAltitude without its reference tag; keep unnamed EXIF tags
check / check (push) Successful in 1m25s
check / check (push) Successful in 1m25s
exif() takes the altitude from the GPSAltitude tag and negates it only when GPSAltitudeRef is 1, so a file with GPSAltitude and no GPSAltitudeRef keeps its altitude, above sea level. A test covers that file. backup-metadata --exif keeps the EXIF tags exifreader has no name for. The comments in src/exif.ts say the thumbnail's tags are not kept and that a tag with several values computes to an array. Model: opus-5-5
This commit is contained in:
@@ -46,6 +46,23 @@ const TIFF_UNSET_DATE = [
|
||||
...new TextEncoder().encode("0000:00:00 00:00:00\0"), // at 56
|
||||
];
|
||||
|
||||
// A big-endian TIFF block holding a GPSAltitude of 12.5 m and no
|
||||
// GPSAltitudeRef.
|
||||
const TIFF_ALTITUDE_WITHOUT_REF = [
|
||||
...[0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x08], // the first IFD at 8
|
||||
// The first IFD, at 8: one entry, then no next IFD.
|
||||
...[0x00, 0x01],
|
||||
// The GPS IFD's offset (0x8825), LONG, 26.
|
||||
...[0x88, 0x25, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1a],
|
||||
...[0x00, 0x00, 0x00, 0x00],
|
||||
// The GPS IFD, at 26: one entry, then no next IFD.
|
||||
...[0x00, 0x01],
|
||||
// GPSAltitude (0x0006), one RATIONAL at 44.
|
||||
...[0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2c],
|
||||
...[0x00, 0x00, 0x00, 0x00],
|
||||
...[0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x02], // 25/2, at 44
|
||||
];
|
||||
|
||||
// An APP1 segment whose length field matches its data.
|
||||
const app1 = (data: number[]): number[] => {
|
||||
const len = data.length + 2;
|
||||
@@ -70,6 +87,13 @@ describe("readPhotoExif", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("reads a GPSAltitude without GPSAltitudeRef as above sea level", () => {
|
||||
const data = [...EXIF_HEADER, ...TIFF_ALTITUDE_WITHOUT_REF];
|
||||
expect(readPhotoExif(bytes(SOI, app1(data), SOS))).toStrictEqual({
|
||||
gpsAltitude: 12.5,
|
||||
});
|
||||
});
|
||||
|
||||
it.each([
|
||||
[
|
||||
"a file that is not an image",
|
||||
|
||||
Reference in New Issue
Block a user