@@ -193,7 +193,6 @@ void PngImage::printStructure(std::ostream& out, PrintStructureOption option, in
193193 const auto exifKey = upper (" Raw profile type exif" );
194194 const auto app1Key = upper (" Raw profile type APP1" );
195195 const auto iptcKey = upper (" Raw profile type iptc" );
196- const auto iccKey = upper (" icc" );
197196 const auto softKey = upper (" Software" );
198197 const auto commKey = upper (" Comment" );
199198 const auto descKey = upper (" Description" );
@@ -272,13 +271,12 @@ void PngImage::printStructure(std::ostream& out, PrintStructureOption option, in
272271 // for XMP, ICC etc: read and format data
273272 const auto dataStringU = upper (dataString);
274273 bool bXMP = option == kpsXMP && findi (dataStringU, xmpKey) == 0 ;
275- bool bICC = option == kpsIccProfile && findi (dataStringU, iccKey) == 0 ;
276274 bool bExif = option == kpsRecursive && (findi (dataStringU, exifKey) == 0 || findi (dataStringU, app1Key) == 0 );
277275 bool bIptc = option == kpsRecursive && findi (dataStringU, iptcKey) == 0 ;
278276 bool bSoft = option == kpsRecursive && findi (dataStringU, softKey) == 0 ;
279277 bool bComm = option == kpsRecursive && findi (dataStringU, commKey) == 0 ;
280278 bool bDesc = option == kpsRecursive && findi (dataStringU, descKey) == 0 ;
281- bool bDump = bXMP || bICC || bExif || bIptc || bSoft || bComm || bDesc || eXIf;
279+ bool bDump = bXMP || bExif || bIptc || bSoft || bComm || bDesc || iCCP || eXIf;
282280
283281 if (bDump) {
284282 DataBuf dataBuf;
@@ -346,7 +344,7 @@ void PngImage::printStructure(std::ostream& out, PrintStructureOption option, in
346344 bLF = true ;
347345 }
348346
349- if (bICC || bComm) {
347+ if ((iCCP && option == kpsIccProfile) || bComm) {
350348 out.write (dataBuf.c_str (), dataBuf.size ());
351349 bLF = bComm;
352350 }
@@ -356,6 +354,7 @@ void PngImage::printStructure(std::ostream& out, PrintStructureOption option, in
356354 out.write (decoded.c_str (), decoded.size ());
357355 bLF = true ;
358356 }
357+
359358 if (eXIf && option == kpsRecursive) {
360359 // create memio object with the data, then print the structure
361360 MemIo p (data.c_data (), dataOffset);
@@ -546,9 +545,14 @@ void PngImage::doWriteMetadata(BasicIo& outIo) {
546545 throw Error (ErrorCode::kerImageWriteFailed);
547546 return ;
548547 }
549- if (!strcmp (szChunk, " eXIf" )) {
550- ; // do nothing Exif metadata is written following IHDR
551- ; // as zTXt chunk with signature Raw profile type exif__
548+ if (!strcmp (szChunk, " eXIf" ) || !strcmp (szChunk, " iCCP" )) {
549+ // do nothing (strip): Exif metadata is written following IHDR
550+ // as zTXt chunk with signature "Raw profile type exif",
551+ // together with the ICC profile as a fresh iCCP chunk
552+ #ifdef EXIV2_DEBUG_MESSAGES
553+ std::cout << " Exiv2::PngImage::doWriteMetadata: strip " << szChunk << " chunk (length: " << dataOffset << " )"
554+ << std::endl;
555+ #endif
552556 } else if (!strcmp (szChunk, " IHDR" )) {
553557#ifdef EXIV2_DEBUG_MESSAGES
554558 std::cout << " Exiv2::PngImage::doWriteMetadata: Write IHDR chunk (length: " << dataOffset << " )\n " ;
@@ -636,13 +640,11 @@ void PngImage::doWriteMetadata(BasicIo& outIo) {
636640 throw Error (ErrorCode::kerImageWriteFailed);
637641 }
638642 }
639- } else if (!strcmp (szChunk, " tEXt" ) || !strcmp (szChunk, " zTXt" ) || !strcmp (szChunk, " iTXt" ) ||
640- !strcmp (szChunk, " iCCP" )) {
643+ } else if (!strcmp (szChunk, " tEXt" ) || !strcmp (szChunk, " zTXt" ) || !strcmp (szChunk, " iTXt" )) {
641644 DataBuf key = PngChunk::keyTXTChunk (chunkBuf, true );
642645 if (!key.empty () && (compare (" Raw profile type exif" , key) || compare (" Raw profile type APP1" , key) ||
643646 compare (" Raw profile type iptc" , key) || compare (" Raw profile type xmp" , key) ||
644- compare (" XML:com.adobe.xmp" , key) || compare (" icc" , key) || // see test/data/imagemagick.png
645- compare (" ICC" , key) || compare (" Description" , key))) {
647+ compare (" XML:com.adobe.xmp" , key) || compare (" Description" , key))) {
646648#ifdef EXIV2_DEBUG_MESSAGES
647649 std::cout << " Exiv2::PngImage::doWriteMetadata: strip " << szChunk << " chunk (length: " << dataOffset << " )"
648650 << std::endl;
0 commit comments