|
|
|
@ -480,7 +480,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
bool Converter::prepareExifTarget(const char* to, bool force)
|
|
|
|
|
{
|
|
|
|
|
Exiv2::ExifData::iterator pos = exifData_->findKey(ExifKey(to));
|
|
|
|
|
auto pos = exifData_->findKey(ExifKey(to));
|
|
|
|
|
if (pos == exifData_->end()) return true;
|
|
|
|
|
if (!overwrite_ && !force) return false;
|
|
|
|
|
exifData_->erase(pos);
|
|
|
|
@ -489,7 +489,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
bool Converter::prepareIptcTarget(const char* to, bool force)
|
|
|
|
|
{
|
|
|
|
|
Exiv2::IptcData::iterator pos = iptcData_->findKey(IptcKey(to));
|
|
|
|
|
auto pos = iptcData_->findKey(IptcKey(to));
|
|
|
|
|
if (pos == iptcData_->end()) return true;
|
|
|
|
|
if (!overwrite_ && !force) return false;
|
|
|
|
|
while ((pos = iptcData_->findKey(IptcKey(to))) != iptcData_->end()) {
|
|
|
|
@ -500,7 +500,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
bool Converter::prepareXmpTarget(const char* to, bool force)
|
|
|
|
|
{
|
|
|
|
|
Exiv2::XmpData::iterator pos = xmpData_->findKey(XmpKey(to));
|
|
|
|
|
auto pos = xmpData_->findKey(XmpKey(to));
|
|
|
|
|
if (pos == xmpData_->end()) return true;
|
|
|
|
|
if (!overwrite_ && !force) return false;
|
|
|
|
|
xmpData_->erase(pos);
|
|
|
|
@ -509,7 +509,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
void Converter::cnvExifValue(const char* from, const char* to)
|
|
|
|
|
{
|
|
|
|
|
Exiv2::ExifData::iterator pos = exifData_->findKey(ExifKey(from));
|
|
|
|
|
auto pos = exifData_->findKey(ExifKey(from));
|
|
|
|
|
if (pos == exifData_->end()) return;
|
|
|
|
|
std::string value = pos->toString();
|
|
|
|
|
if (!pos->value().ok()) {
|
|
|
|
@ -525,7 +525,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
void Converter::cnvExifComment(const char* from, const char* to)
|
|
|
|
|
{
|
|
|
|
|
Exiv2::ExifData::iterator pos = exifData_->findKey(ExifKey(from));
|
|
|
|
|
auto pos = exifData_->findKey(ExifKey(from));
|
|
|
|
|
if (pos == exifData_->end()) return;
|
|
|
|
|
if (!prepareXmpTarget(to)) return;
|
|
|
|
|
const CommentValue* cv = dynamic_cast<const CommentValue*>(&pos->value());
|
|
|
|
@ -542,7 +542,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
void Converter::cnvExifArray(const char* from, const char* to)
|
|
|
|
|
{
|
|
|
|
|
Exiv2::ExifData::iterator pos = exifData_->findKey(ExifKey(from));
|
|
|
|
|
auto pos = exifData_->findKey(ExifKey(from));
|
|
|
|
|
if (pos == exifData_->end()) return;
|
|
|
|
|
if (!prepareXmpTarget(to)) return;
|
|
|
|
|
for (int i = 0; i < pos->count(); ++i) {
|
|
|
|
@ -560,7 +560,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
void Converter::cnvExifDate(const char* from, const char* to)
|
|
|
|
|
{
|
|
|
|
|
Exiv2::ExifData::iterator pos = exifData_->findKey(ExifKey(from));
|
|
|
|
|
auto pos = exifData_->findKey(ExifKey(from));
|
|
|
|
|
if (pos == exifData_->end()) return;
|
|
|
|
|
if (!prepareXmpTarget(to)) return;
|
|
|
|
|
int year, month, day, hour, min, sec;
|
|
|
|
@ -629,7 +629,7 @@ namespace Exiv2 {
|
|
|
|
|
buf[1] = '.'; // some locales use ','
|
|
|
|
|
subsec = buf + 1;
|
|
|
|
|
|
|
|
|
|
Exiv2::ExifData::iterator datePos = exifData_->findKey(ExifKey("Exif.GPSInfo.GPSDateStamp"));
|
|
|
|
|
auto datePos = exifData_->findKey(ExifKey("Exif.GPSInfo.GPSDateStamp"));
|
|
|
|
|
if (datePos == exifData_->end()) {
|
|
|
|
|
datePos = exifData_->findKey(ExifKey("Exif.Photo.DateTimeOriginal"));
|
|
|
|
|
}
|
|
|
|
@ -664,7 +664,7 @@ namespace Exiv2 {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (subsecTag) {
|
|
|
|
|
ExifData::iterator subsec_pos = exifData_->findKey(ExifKey(subsecTag));
|
|
|
|
|
auto subsec_pos = exifData_->findKey(ExifKey(subsecTag));
|
|
|
|
|
if ( subsec_pos != exifData_->end()
|
|
|
|
|
&& subsec_pos->typeId() == asciiString) {
|
|
|
|
|
std::string ss = subsec_pos->toString();
|
|
|
|
@ -688,7 +688,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
void Converter::cnvExifVersion(const char* from, const char* to)
|
|
|
|
|
{
|
|
|
|
|
Exiv2::ExifData::iterator pos = exifData_->findKey(ExifKey(from));
|
|
|
|
|
auto pos = exifData_->findKey(ExifKey(from));
|
|
|
|
|
if (pos == exifData_->end()) return;
|
|
|
|
|
if (!prepareXmpTarget(to)) return;
|
|
|
|
|
std::ostringstream value;
|
|
|
|
@ -701,7 +701,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
void Converter::cnvExifGPSVersion(const char* from, const char* to)
|
|
|
|
|
{
|
|
|
|
|
Exiv2::ExifData::iterator pos = exifData_->findKey(ExifKey(from));
|
|
|
|
|
auto pos = exifData_->findKey(ExifKey(from));
|
|
|
|
|
if (pos == exifData_->end()) return;
|
|
|
|
|
if (!prepareXmpTarget(to)) return;
|
|
|
|
|
std::ostringstream value;
|
|
|
|
@ -715,7 +715,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
void Converter::cnvExifFlash(const char* from, const char* to)
|
|
|
|
|
{
|
|
|
|
|
Exiv2::ExifData::iterator pos = exifData_->findKey(ExifKey(from));
|
|
|
|
|
auto pos = exifData_->findKey(ExifKey(from));
|
|
|
|
|
if (pos == exifData_->end() || pos->count() == 0) return;
|
|
|
|
|
if (!prepareXmpTarget(to)) return;
|
|
|
|
|
int value = pos->toLong();
|
|
|
|
@ -737,7 +737,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
void Converter::cnvExifGPSCoord(const char* from, const char* to)
|
|
|
|
|
{
|
|
|
|
|
Exiv2::ExifData::iterator pos = exifData_->findKey(ExifKey(from));
|
|
|
|
|
auto pos = exifData_->findKey(ExifKey(from));
|
|
|
|
|
if (pos == exifData_->end()) return;
|
|
|
|
|
if (!prepareXmpTarget(to)) return;
|
|
|
|
|
if (pos->count() != 3) {
|
|
|
|
@ -746,7 +746,7 @@ namespace Exiv2 {
|
|
|
|
|
#endif
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Exiv2::ExifData::iterator refPos = exifData_->findKey(ExifKey(std::string(from) + "Ref"));
|
|
|
|
|
auto refPos = exifData_->findKey(ExifKey(std::string(from) + "Ref"));
|
|
|
|
|
if (refPos == exifData_->end()) {
|
|
|
|
|
#ifndef SUPPRESS_WARNINGS
|
|
|
|
|
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
|
|
|
@ -781,7 +781,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
void Converter::cnvXmpValue(const char* from, const char* to)
|
|
|
|
|
{
|
|
|
|
|
Exiv2::XmpData::iterator pos = xmpData_->findKey(XmpKey(from));
|
|
|
|
|
auto pos = xmpData_->findKey(XmpKey(from));
|
|
|
|
|
if (pos == xmpData_->end()) return;
|
|
|
|
|
if (!prepareExifTarget(to)) return;
|
|
|
|
|
std::string value;
|
|
|
|
@ -803,7 +803,7 @@ namespace Exiv2 {
|
|
|
|
|
void Converter::cnvXmpComment(const char* from, const char* to)
|
|
|
|
|
{
|
|
|
|
|
if (!prepareExifTarget(to)) return;
|
|
|
|
|
Exiv2::XmpData::iterator pos = xmpData_->findKey(XmpKey(from));
|
|
|
|
|
auto pos = xmpData_->findKey(XmpKey(from));
|
|
|
|
|
if (pos == xmpData_->end()) return;
|
|
|
|
|
std::string value;
|
|
|
|
|
if (!getTextValue(value, pos)) {
|
|
|
|
@ -820,7 +820,7 @@ namespace Exiv2 {
|
|
|
|
|
void Converter::cnvXmpArray(const char* from, const char* to)
|
|
|
|
|
{
|
|
|
|
|
if (!prepareExifTarget(to)) return;
|
|
|
|
|
Exiv2::XmpData::iterator pos = xmpData_->findKey(XmpKey(from));
|
|
|
|
|
auto pos = xmpData_->findKey(XmpKey(from));
|
|
|
|
|
if (pos == xmpData_->end()) return;
|
|
|
|
|
std::ostringstream array;
|
|
|
|
|
for (int i = 0; i < pos->count(); ++i) {
|
|
|
|
@ -840,7 +840,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
void Converter::cnvXmpDate(const char* from, const char* to)
|
|
|
|
|
{
|
|
|
|
|
Exiv2::XmpData::iterator pos = xmpData_->findKey(XmpKey(from));
|
|
|
|
|
auto pos = xmpData_->findKey(XmpKey(from));
|
|
|
|
|
if (pos == xmpData_->end()) return;
|
|
|
|
|
if (!prepareExifTarget(to)) return;
|
|
|
|
|
#ifdef EXV_HAVE_XMP_TOOLKIT
|
|
|
|
@ -938,7 +938,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
void Converter::cnvXmpVersion(const char* from, const char* to)
|
|
|
|
|
{
|
|
|
|
|
Exiv2::XmpData::iterator pos = xmpData_->findKey(XmpKey(from));
|
|
|
|
|
auto pos = xmpData_->findKey(XmpKey(from));
|
|
|
|
|
if (pos == xmpData_->end()) return;
|
|
|
|
|
if (!prepareExifTarget(to)) return;
|
|
|
|
|
std::string value = pos->toString();
|
|
|
|
@ -961,7 +961,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
void Converter::cnvXmpGPSVersion(const char* from, const char* to)
|
|
|
|
|
{
|
|
|
|
|
Exiv2::XmpData::iterator pos = xmpData_->findKey(XmpKey(from));
|
|
|
|
|
auto pos = xmpData_->findKey(XmpKey(from));
|
|
|
|
|
if (pos == xmpData_->end()) return;
|
|
|
|
|
if (!prepareExifTarget(to)) return;
|
|
|
|
|
std::string value = pos->toString();
|
|
|
|
@ -982,7 +982,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
void Converter::cnvXmpFlash(const char* from, const char* to)
|
|
|
|
|
{
|
|
|
|
|
Exiv2::XmpData::iterator pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:Fired"));
|
|
|
|
|
auto pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:Fired"));
|
|
|
|
|
if (pos == xmpData_->end()) return;
|
|
|
|
|
if (!prepareExifTarget(to)) return;
|
|
|
|
|
unsigned short value = 0;
|
|
|
|
@ -1043,7 +1043,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
void Converter::cnvXmpGPSCoord(const char* from, const char* to)
|
|
|
|
|
{
|
|
|
|
|
Exiv2::XmpData::iterator pos = xmpData_->findKey(XmpKey(from));
|
|
|
|
|
auto pos = xmpData_->findKey(XmpKey(from));
|
|
|
|
|
if (pos == xmpData_->end()) return;
|
|
|
|
|
if (!prepareExifTarget(to)) return;
|
|
|
|
|
std::string value = pos->toString();
|
|
|
|
@ -1107,7 +1107,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
void Converter::cnvIptcValue(const char* from, const char* to)
|
|
|
|
|
{
|
|
|
|
|
Exiv2::IptcData::iterator pos = iptcData_->findKey(IptcKey(from));
|
|
|
|
|
auto pos = iptcData_->findKey(IptcKey(from));
|
|
|
|
|
if (pos == iptcData_->end()) return;
|
|
|
|
|
if (!prepareXmpTarget(to)) return;
|
|
|
|
|
while (pos != iptcData_->end()) {
|
|
|
|
@ -1133,7 +1133,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
void Converter::cnvXmpValueToIptc(const char* from, const char* to)
|
|
|
|
|
{
|
|
|
|
|
XmpData::iterator pos = xmpData_->findKey(XmpKey(from));
|
|
|
|
|
auto pos = xmpData_->findKey(XmpKey(from));
|
|
|
|
|
if (pos == xmpData_->end()) return;
|
|
|
|
|
if (!prepareIptcTarget(to)) return;
|
|
|
|
|
|
|
|
|
@ -1188,7 +1188,7 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
if (!res.str().empty()) res << ',';
|
|
|
|
|
res << key.tag();
|
|
|
|
|
Exiv2::ExifData::iterator pos = exifData_->findKey(key);
|
|
|
|
|
auto pos = exifData_->findKey(key);
|
|
|
|
|
if (pos == exifData_->end()) continue;
|
|
|
|
|
DataBuf data(pos->size());
|
|
|
|
|
pos->copy(data.pData_, littleEndian /* FIXME ? */);
|
|
|
|
@ -1221,8 +1221,8 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
void Converter::syncExifWithXmp()
|
|
|
|
|
{
|
|
|
|
|
Exiv2::XmpData::iterator td = xmpData_->findKey(XmpKey("Xmp.tiff.NativeDigest"));
|
|
|
|
|
Exiv2::XmpData::iterator ed = xmpData_->findKey(XmpKey("Xmp.exif.NativeDigest"));
|
|
|
|
|
auto td = xmpData_->findKey(XmpKey("Xmp.tiff.NativeDigest"));
|
|
|
|
|
auto ed = xmpData_->findKey(XmpKey("Xmp.exif.NativeDigest"));
|
|
|
|
|
if (td != xmpData_->end() && ed != xmpData_->end()) {
|
|
|
|
|
if (td->value().toString() == computeExifDigest(true) &&
|
|
|
|
|
ed->value().toString() == computeExifDigest(false)) {
|
|
|
|
|