Skip to content

Commit 11b7414

Browse files
authored
Fix/webp exif little endian (#4061)
* Fix for isLittleEndian flag in parseExifData. * Add break after reading first exif chunk in getWebpMetadata.
1 parent 6ab8cad commit 11b7414

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

web/scripts/pnginfo.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function getPngMetadata(file) {
4949

5050
function parseExifData(exifData) {
5151
// Check for the correct TIFF header (0x4949 for little-endian or 0x4D4D for big-endian)
52-
const isLittleEndian = new Uint16Array(exifData.slice(0, 2))[0] === 0x4949;
52+
const isLittleEndian = String.fromCharCode(...exifData.slice(0, 2)) === "II";
5353

5454
// Function to read 16-bit and 32-bit integers from binary data
5555
function readInt(offset, isLittleEndian, length) {
@@ -134,6 +134,7 @@ export function getWebpMetadata(file) {
134134
let index = value.indexOf(':');
135135
txt_chunks[value.slice(0, index)] = value.slice(index + 1);
136136
}
137+
break;
137138
}
138139

139140
offset += 8 + chunk_length;

0 commit comments

Comments
 (0)