From e7cefa3dc42a77075a46ffab9eb638c41f1bc147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Komar=C4=8Devi=C4=87?= Date: Mon, 19 Sep 2022 12:26:03 +0200 Subject: [PATCH] API for setting profile name for PNGs --- include/exiv2/image.hpp | 2 +- include/exiv2/pngimage.hpp | 16 +++++++++++++++- src/pngimage.cpp | 10 ++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/exiv2/image.hpp b/include/exiv2/image.hpp index bb4e46986b..cb5bd6937f 100644 --- a/include/exiv2/image.hpp +++ b/include/exiv2/image.hpp @@ -192,7 +192,7 @@ class EXIV2API Image { */ virtual void setIccProfile(DataBuf&& iccProfile, bool bTestValid = true); /*! - @brief Erase iccProfile. the profile is not removed from + @brief Erase iccProfile. The profile is not removed from the actual image until the writeMetadata() method is called. */ virtual void clearIccProfile(); diff --git a/include/exiv2/pngimage.hpp b/include/exiv2/pngimage.hpp index efcb1cc338..6471e3f87d 100644 --- a/include/exiv2/pngimage.hpp +++ b/include/exiv2/pngimage.hpp @@ -53,6 +53,20 @@ class EXIV2API PngImage : public Image { @warning This function is not thread safe and intended for exiv2 -pS for debugging. */ void printStructure(std::ostream& out, PrintStructureOption option, size_t depth) override; + /*! + @brief Set the image iccProfile. The new profile is not written + to the image until the writeMetadata() method is called. + @param iccProfile DataBuf containing profile (binary) + @param bTestValid - tests that iccProfile contains credible data + @param profileName Name for referring to the profile + */ + void setIccProfile(DataBuf&& iccProfile, bool bTestValid = true, + const std::string& profileName = std::string("ICC profile")); + /*! + @brief Erase iccProfile. The profile is not removed from + the actual image until the writeMetadata() method is called. + */ + void clearIccProfile() override; //@} //! @name Accessors @@ -79,7 +93,7 @@ class EXIV2API PngImage : public Image { void doWriteMetadata(BasicIo& outIo); //@} - std::string profileName_{"ICC Profile"}; + std::string profileName_{"ICC profile"}; }; // class PngImage diff --git a/src/pngimage.cpp b/src/pngimage.cpp index 6879f9735a..7c32909a1e 100644 --- a/src/pngimage.cpp +++ b/src/pngimage.cpp @@ -373,6 +373,16 @@ void PngImage::printStructure(std::ostream& out, PrintStructureOption option, si } } +void PngImage::setIccProfile(DataBuf&& iccProfile, bool bTestValid, const std::string& profileName) { + profileName_ = profileName; + Image::setIccProfile(std::move(iccProfile), bTestValid); +} + +void PngImage::clearIccProfile() { + profileName_ = std::string("ICC profile"); + Image::clearIccProfile(); +} + void readChunk(DataBuf& buffer, BasicIo& io) { #ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngImage::readMetadata: Position: " << io.tell() << std::endl;