Skip to content

Commit e8e86a5

Browse files
committed
fix: fix bug with exifData.saveData not saving correct bytes
1 parent 272f242 commit e8e86a5

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

.changeset/sour-impalas-flow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"libexif-wasm": patch
3+
---
4+
5+
fix bug with exifData.saveData not saving correct bytes

src/libexif/ExifData.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,23 @@ describe("ExifData", () => {
180180
});
181181
},
182182
);
183+
describe.each(["T-45A_Goshawk_03.jpg", "Sumo_Museum.jpg"])(
184+
"ExifData.newFromData(%s)",
185+
(testFixtureFile) => {
186+
test("should save data with correct Exif header", async () => {
187+
const testFixture = await getTestFixture(testFixtureFile);
188+
const exifData = withDisposable(
189+
ExifData.newFromData(testFixture.buffer),
190+
);
191+
const data = exifData.saveData();
192+
expect(
193+
new Uint8Array([0x45, 0x78, 0x69, 0x66, 0x00, 0x00]).every(
194+
(value, index) => data[index] === value,
195+
),
196+
).toBe(true);
197+
});
198+
},
199+
);
183200
});
184201

185202
const EXIF_DATA_OPTION_TABLE = [

src/libexif/ExifData.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,6 @@ class ExifData extends ExifDataStruct implements DisposableDataSegment {
207207
}
208208

209209
const data = HEAPU8.subarray(dataPtr, dataPtr + dataSize);
210-
const exifMem = new ExifMem(dataPtr);
211-
exifMem.unref();
212210
return data;
213211
}
214212

0 commit comments

Comments
 (0)