From 6b3d63e11b1a2c662d8574915065eea29a87e67a Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Sat, 23 Mar 2024 14:42:02 -0500 Subject: [PATCH] Search all APP2 sections for ICC profile data Apple phones often include several images in one file using the Multi-Picture Format standard. This is implemented via a MPF0 object within an APP2 section. Pel should search for the ICC section instead of returning the first APP2 section. --- src/PelJpeg.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/PelJpeg.php b/src/PelJpeg.php index 556b676a..fe254cf2 100644 --- a/src/PelJpeg.php +++ b/src/PelJpeg.php @@ -402,8 +402,14 @@ public function getExif() */ public function getICC() { - $icc = $this->getSection(PelJpegMarker::APP2); - return $icc; + $skip = 0; + while ($icc = $this->getSection(PelJpegMarker::APP2, $skip)) { + if (str_starts_with($icc->getBytes(), "ICC_PROFILE")) { + return $icc; + } + $skip ++; + } + return null; } /**