From a07d97a9d35cf3f6f57161f7fcc9adb841d9f647 Mon Sep 17 00:00:00 2001 From: Kyosuke Fujimoto Date: Wed, 28 Aug 2024 16:21:34 +0900 Subject: [PATCH 1/2] Add test for jpg without APP segment to IIPMetrics --- .../fixture/testimages/w3c_home_noexif.jpg | Bin 0 -> 2147 bytes addons/addon-image/src/IIPMetrics.test.ts | 1 + 2 files changed, 1 insertion(+) create mode 100644 addons/addon-image/fixture/testimages/w3c_home_noexif.jpg diff --git a/addons/addon-image/fixture/testimages/w3c_home_noexif.jpg b/addons/addon-image/fixture/testimages/w3c_home_noexif.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a46c97ce668f3ace815465d0128252974e20a9de GIT binary patch literal 2147 zcmbW%do=8@z` z2IC}DO!5ew9wZu}Vu<3H%%sD_nBSSsx$B;_`s>{LU2E@u_IG{P{(SfPZs;{M1hxP) z5`{(~(P$JJgF!1{)v;J*Wvu2hHJrMRrmn7zrnWY5xha{bZ)~8gZMe$Nm}0ile5D?l zW=W%3no?I%zZHRDFc_>7mVm_)s6=fd^?wei8Q_(GC2&K)i~t-DL*QZ1BR~cKhJyVW z;6DL_BNX?=C@EuA6bW_e01iVS;79}tg+wZ{6BXwGiAQOySi2cb*uEEI6sc*&zErGa z>~y2#_1c8jvHwU1b9--#Zqw#ho7 zspK2&PuV|%CH-Hr|HA%u4FVhjrg%IA9?-!&1f&d-5(J8E+gMVIWC)xqk!y7((LZ{M zhvnE22#kh5V;vgG2zCRxcrt+bJh+P z<-3oj`bJdd_nJ3no(&7$kis3ucBtr@2d{;?qMVQs$yyFz-%ff+> z7^L~00@C{>Ow}=mrnP5paw#_s82F#qemv|$9RynMiCveJoAe>j5&<}1*y|b^_UG>3R{3O+O$6L1+auw5~ys7xQW211-qmKFWSyY3@tzA0g zz=8SE2N#jrl&q4~8T8y8-R?TVS7RHJ89&?s64i+W1IUBz$ zvxWeSH$2AVj6S?zXO>EPb0zs{ibSTm5+{;U+N8b^Ao7C z&2tE_G$Ak??KQG4mSiC<=1TK@U_Y~o`+g9HWQ}`oN}B0>!8pQoIXuSL+TXQc@I-^N zXg$>n0qZSuS0uaHGzZhNi4A_*;e~uSW}$Wg7b^eyg*P@rDHcvLwNR<-wYD~6iPI-| z1GuVJ>7O<<8(ss;onsSnE|gA%8%^0o7rwX@bGHzC-?-O=(M2M%9n=;#*XQr0JVmTM zQ$Z*BUP{AyEt-^nSmgJk%y2GxJ(-#2@-pAPTLM2)`Q*n0`t++}UjB%3-Nsxw#qRmi z^S8afd_AX815UF~X0~S}Fa$d0XFanZy4qw0OTBRhE9U4(*N9lPqzp@rP3-x*FE2X=v^wsUia7Gc zYEQ+maumaAz*h`wvKw96kkMoqr_9rck;JAvlT;YFMO!33socD0+4Pwho-0#r+pt=Y zuYTlIo>hgrue)RB_)NOp8kvcsieO!HT{ zueK*!W+vI08%xC{PL0x(u_cd3gRknNULLS|&&>Q(irjWew6nV&Q z4u7%VbaRB-$=GmX*klf+dQb|1W}BQzRP_ZW4T-;K5;?VVin|G@vIBiOdbj7+q?FPW zznN~Qsy#10kd~?JxSG}4(8N-ed7uB{38U{5>`Qx=DTmDmo_X(n5e@Ly;vRReiIwOx zq&=fc)@^c7-*{Ur%6?;;ms4sdI=JhN6%S^Jt5zwvjku0}aFQY6v_%~3pC0T?=aX3x z1z#Bq!ONS8$DcXdZ<7?YWf=8DL=|boId!~>S04)Y- Date: Wed, 28 Aug 2024 16:22:21 +0900 Subject: [PATCH 2/2] Fix IIPMetrics jpg detection --- addons/addon-image/src/IIPMetrics.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/addons/addon-image/src/IIPMetrics.ts b/addons/addon-image/src/IIPMetrics.ts index 03770c4388..d5470466f9 100644 --- a/addons/addon-image/src/IIPMetrics.ts +++ b/addons/addon-image/src/IIPMetrics.ts @@ -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 }; }