--- a/src/gimage.cpp +++ b/src/gimage.cpp 2026-01-25 09:12:18.000000000 +0800 @@ -6788,7 +6788,7 @@ { Exiv2::ExifData exifData; int numerator, denominator; - + for (std::vector::iterator it=taglist.begin(); it!=taglist.end(); ++it) { //printf("%s %ld: ",(*it).c_str(), Exiv2::ExifKey(*it).defaultTypeId()); //keep for debugging std::string name = split(*it,".")[2]; @@ -6841,22 +6841,24 @@ } exifData.sortByTag(); - + auto image = Exiv2::ImageFactory::open(filename); image->setExifData(exifData); if (profile != NULL) { char * iccprofile; cmsUInt32Number iccprofilesize; makeICCProfile(profile, iccprofile, iccprofilesize); - Exiv2::DataBuf iccprof((Exiv2::byte *) iccprofile, iccprofilesize); - image->setIccProfile(iccprof); + // Exiv2 0.28.x: + Exiv2::DataBuf iccprof(iccprofilesize); + std::memcpy(iccprof.data(), iccprofile, iccprofilesize); + image->setIccProfile(std::move(iccprof)); delete [] iccprofile; } - + try { image->writeMetadata(); } - catch (Exiv2::AnyError& e) { + catch (Exiv2::Error& e) { return GIMAGE_EXIV2_METADATAWRITE_FAILED; } @@ -6869,7 +6871,7 @@ std::map imgdata; Exiv2::LogMsg::setLevel(Exiv2::LogMsg::error); //suppress all exiv2 messages to stderr except errors int i; - + try { auto image = Exiv2::ImageFactory::open(filename); //assert(image.get() != 0); @@ -6895,7 +6897,7 @@ case Exiv2::signedLong: case Exiv2::unsignedLongLong: case Exiv2::signedLongLong: - imgdata[name] = tostr((unsigned short) exifData[*it].toLong()); + imgdata[name] = tostr((unsigned short) exifData[*it].toInt64()); break; case Exiv2::asciiString: case Exiv2::date: @@ -6907,22 +6909,22 @@ } } } - catch (Exiv2::AnyError& e) { + catch (Exiv2::Error& e) { imgdata["Error"] = "Metadata read failure."; return imgdata; } - + return imgdata; } //loads metadata from a file into the gImage instance: GIMAGE_ERROR gImage::getMetadata(std::string filename) -{ +{ //debugging: displays any data collected prior to using exiv2: //for (std::map::iterator it=imginfo.begin(); it!=imginfo.end(); ++it) { // printf("%s: %s\n",it->first.c_str(), it->second.c_str()); fflush(stdout); //} - + std::map imdat = loadMetadata(filename.c_str()); if (imdat.find("Error") != imdat.end()) { @@ -6932,16 +6934,19 @@ for (std::map::iterator it=imdat.begin(); it!=imdat.end(); ++it) imginfo[it->first] = it->second; - + auto image = Exiv2::ImageFactory::open(filename); assert(image.get() != 0); image->readMetadata(); char * prof; if (image->iccProfileDefined()) { - prof = new char[image->iccProfile()->size_]; - memcpy(prof, image->iccProfile()->pData_, image->iccProfile()->size_); - setProfile(prof, image->iccProfile()->size_); + // iccProfile() returns const DataBuf& + // Need to make a copy to get non-const access + Exiv2::DataBuf iccBuf = image->iccProfile(); + prof = new char[iccBuf.size()]; + memcpy(prof, iccBuf.data(), iccBuf.size()); + setProfile(prof, iccBuf.size()); } return GIMAGE_OK;