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 30, 2022
1 parent 7ebf2a1 commit cdf32cb
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 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,13 +641,11 @@ 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) ||
compare("XML:com.adobe.xmp", key) || compare("icc", key) || // see test/data/imagemagick.png
compare("ICC", key) || compare("Description", key))) {
compare("XML:com.adobe.xmp", key) || compare("Description", key))) {
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::PngImage::doWriteMetadata: strip " << szChunk << " chunk (length: " << dataOffset << ")"
<< std::endl;
Expand Down

0 comments on commit cdf32cb

Please sign in to comment.