Skip to content

Commit

Permalink
Merge pull request #5139 from lusingander/image-addon-iip-jpeg
Browse files Browse the repository at this point in the history
Fix image addon not being able to render some jpeg images in IIP
  • Loading branch information
jerch authored Aug 28, 2024
2 parents f186475 + b307adb commit 1b48cd0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions addons/addon-image/src/IIPMetrics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const TEST_IMAGES: [string, IMetrics][] = [
['w3c_home_gray.png', { mime: 'image/png', width: 72, height: 48 }],
['w3c_home.jpg', { mime: 'image/jpeg', width: 72, height: 48 }],
['w3c_home.png', { mime: 'image/png', width: 72, height: 48 }],
['w3c_home_noexif.jpg', { mime: 'image/jpeg', width: 72, height: 48 }],
['spinfox.png', { mime: 'image/png', width: 148, height: 148 }],
['iphone_hdr_YES.jpg', { mime: 'image/jpeg', width: 3264, height: 2448 }],
['nikon-e950.jpg', { mime: 'image/jpeg', width: 800, height: 600 }],
Expand Down
9 changes: 2 additions & 7 deletions addons/addon-image/src/IIPMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,8 @@ export function imageType(d: Uint8Array): IMetrics {
height: d[20] << 24 | d[21] << 16 | d[22] << 8 | d[23]
};
}
// JPEG: FF D8 FF E0 xx xx JFIF or FF D8 FF E1 xx xx Exif 00 00
if ((d32[0] === 0xE0FFD8FF || d32[0] === 0xE1FFD8FF)
&& (
(d[6] === 0x4a && d[7] === 0x46 && d[8] === 0x49 && d[9] === 0x46)
|| (d[6] === 0x45 && d[7] === 0x78 && d[8] === 0x69 && d[9] === 0x66)
)
) {
// JPEG: FF D8 FF
if (d[0] === 0xFF && d[1] === 0xD8 && d[2] === 0xFF) {
const [width, height] = jpgSize(d);
return { mime: 'image/jpeg', width, height };
}
Expand Down

0 comments on commit 1b48cd0

Please sign in to comment.