Skip to content

Commit

Permalink
PNG: always strip the existing iCCP chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
kmilos committed Jun 29, 2022
1 parent 7ebf2a1 commit cf38bf3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/pngimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ void PngImage::printStructure(std::ostream& out, PrintStructureOption option, in
bool bSoft = option == kpsRecursive && findi(dataStringU, softKey) == 0;
bool bComm = option == kpsRecursive && findi(dataStringU, commKey) == 0;
bool bDesc = option == kpsRecursive && findi(dataStringU, descKey) == 0;
bool bDump = bXMP || bICC || bExif || bIptc || bSoft || bComm || bDesc || eXIf;
bool bDump = bXMP || bICC || bExif || bIptc || bSoft || bComm || bDesc || iCCP || eXIf;

if (bDump) {
DataBuf dataBuf;
Expand Down Expand Up @@ -546,9 +546,14 @@ void PngImage::doWriteMetadata(BasicIo& outIo) {
throw Error(ErrorCode::kerImageWriteFailed);
return;
}
if (!strcmp(szChunk, "eXIf")) {
; // do nothing Exif metadata is written following IHDR
; // as zTXt chunk with signature Raw profile type exif__
if (!strcmp(szChunk, "eXIf") || !strcmp(szChunk, "iCCP")) {
// do nothing (strip): Exif metadata is written following IHDR
// as zTXt chunk with signature "Raw profile type exif",
// together with the ICC profile as a fresh iCCP chunk
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::PngImage::doWriteMetadata: strip " << szChunk << " chunk (length: " << dataOffset << ")"
<< std::endl;
#endif
} else if (!strcmp(szChunk, "IHDR")) {
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::PngImage::doWriteMetadata: Write IHDR chunk (length: " << dataOffset << ")\n";
Expand Down Expand Up @@ -636,8 +641,7 @@ void PngImage::doWriteMetadata(BasicIo& outIo) {
throw Error(ErrorCode::kerImageWriteFailed);
}
}
} else if (!strcmp(szChunk, "tEXt") || !strcmp(szChunk, "zTXt") || !strcmp(szChunk, "iTXt") ||
!strcmp(szChunk, "iCCP")) {
} else if (!strcmp(szChunk, "tEXt") || !strcmp(szChunk, "zTXt") || !strcmp(szChunk, "iTXt") ||) {
DataBuf key = PngChunk::keyTXTChunk(chunkBuf, true);
if (!key.empty() && (compare("Raw profile type exif", key) || compare("Raw profile type APP1", key) ||
compare("Raw profile type iptc", key) || compare("Raw profile type xmp", key) ||
Expand Down

0 comments on commit cf38bf3

Please sign in to comment.