Skip to content

Commit b307adb

Browse files
committed
Fix IIPMetrics jpg detection
1 parent a07d97a commit b307adb

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

addons/addon-image/src/IIPMetrics.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,8 @@ export function imageType(d: Uint8Array): IMetrics {
3232
height: d[20] << 24 | d[21] << 16 | d[22] << 8 | d[23]
3333
};
3434
}
35-
// JPEG: FF D8 FF E0 xx xx JFIF or FF D8 FF E1 xx xx Exif 00 00
36-
if ((d32[0] === 0xE0FFD8FF || d32[0] === 0xE1FFD8FF)
37-
&& (
38-
(d[6] === 0x4a && d[7] === 0x46 && d[8] === 0x49 && d[9] === 0x46)
39-
|| (d[6] === 0x45 && d[7] === 0x78 && d[8] === 0x69 && d[9] === 0x66)
40-
)
41-
) {
35+
// JPEG: FF D8 FF
36+
if (d[0] === 0xFF && d[1] === 0xD8 && d[2] === 0xFF) {
4237
const [width, height] = jpgSize(d);
4338
return { mime: 'image/jpeg', width, height };
4439
}

0 commit comments

Comments
 (0)