summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2023-09-09 14:52:24 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2023-09-09 14:52:24 +0900
commitad23556fb6483ae515f9464c6e779dff8c7b5bd9 (patch)
tree7dd4bdd1534e2b6005a3c5fece2529d9f7a3392b
parent841f69a0337e4a700b1eb3511e3f46d6317bc4d4 (diff)
downloadlibkexiv2-ad23556fb6483ae515f9464c6e779dff8c7b5bd9.tar.gz
libkexiv2-ad23556fb6483ae515f9464c6e779dff8c7b5bd9.zip
Fix FTBFS when using libexiv2 0.28.0. This resolves issue #3
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r--ChangeLog4
-rw-r--r--libkexiv2/libkexiv2/kexiv2.cpp117
-rw-r--r--libkexiv2/libkexiv2/kexiv2private.cpp18
3 files changed, 131 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 0177835..2bfb575 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -65,8 +65,8 @@ V 0.1.6 - 2007-09-08
2007-08-21 20:48 cgilles
* [r703058] libkexiv2/libkexiv2/kexiv2.cpp:
- use EXIV2_TEST_VERSION instead EXIV2_CHECK_VERSION witch is
- depreciate now
+ use EXIV2_TEST_VERSION instead EXIV2_CHECK_VERSION which is
+ deprecated now
2007-08-21 18:54 cgilles
diff --git a/libkexiv2/libkexiv2/kexiv2.cpp b/libkexiv2/libkexiv2/kexiv2.cpp
index 4c2bafe..a6b879c 100644
--- a/libkexiv2/libkexiv2/kexiv2.cpp
+++ b/libkexiv2/libkexiv2/kexiv2.cpp
@@ -198,9 +198,15 @@ TQByteArray KExiv2::getIptc(bool addIrbHeader) const
c2 = Exiv2::IptcParser::encode(d->iptcMetadata);
}
+#if (EXIV2_TEST_VERSION(0,28,0))
+ TQByteArray data(c2.size());
+ if (data.size())
+ memcpy(data.data(), c2.c_data(), c2.size());
+#else
TQByteArray data(c2.size_);
if (data.size())
memcpy(data.data(), c2.pData_, c2.size_);
+#endif
return data;
}
}
@@ -271,7 +277,11 @@ bool KExiv2::load(const TQByteArray& imgData)
try
{
+#if (EXIV2_TEST_VERSION(0,28,0))
+ Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open((Exiv2::byte*)imgData.data(), imgData.size());
+#else
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open((Exiv2::byte*)imgData.data(), imgData.size());
+#endif
d->filePath = TQString();
image->readMetadata();
@@ -309,8 +319,13 @@ bool KExiv2::load(const TQString& filePath)
try
{
+#if (EXIV2_TEST_VERSION(0,28,0))
+ Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open((const char*)
+ (TQFile::encodeName(filePath)));
+#else
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open((const char*)
(TQFile::encodeName(filePath)));
+#endif
d->filePath = filePath;
image->readMetadata();
@@ -368,8 +383,13 @@ bool KExiv2::save(const TQString& filePath)
try
{
Exiv2::AccessMode mode;
+#if (EXIV2_TEST_VERSION(0,28,0))
+ Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open((const char*)
+ (TQFile::encodeName(filePath)));
+#else
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open((const char*)
(TQFile::encodeName(filePath)));
+#endif
// We need to load target file metadata to merge with new one. It's mandatory with TIFF format:
// like all tiff file structure is based on Exif.
@@ -459,8 +479,8 @@ bool KExiv2::save(const TQString& filePath)
bool KExiv2::applyChanges()
{
if (d->filePath.isEmpty())
- return false;
-
+ return false;
+
return save(d->filePath);
}
@@ -482,8 +502,13 @@ bool KExiv2::canWriteComment(const TQString& filePath)
{
try
{
+#if (EXIV2_TEST_VERSION(0,28,0))
+ Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open((const char*)
+ (TQFile::encodeName(filePath)));
+#else
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open((const char*)
(TQFile::encodeName(filePath)));
+#endif
Exiv2::AccessMode mode = image->checkMode(Exiv2::mdComment);
return (mode == Exiv2::amWrite || mode == Exiv2::amReadWrite);
@@ -491,7 +516,7 @@ bool KExiv2::canWriteComment(const TQString& filePath)
catch( Exiv2::Error &e )
{
std::string s(e.what());
- tqDebug("%s (Error #%i: %s)", "Cannot check Comment access mode using Exiv2 ", e.code(), s.c_str());
+ tqDebug("%s (Error #%i: %s)", "Cannot check Comment access mode using Exiv2 ", (int)e.code(), s.c_str());
}
return false;
@@ -501,8 +526,13 @@ bool KExiv2::canWriteExif(const TQString& filePath)
{
try
{
+#if (EXIV2_TEST_VERSION(0,28,0))
+ Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open((const char*)
+ (TQFile::encodeName(filePath)));
+#else
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open((const char*)
(TQFile::encodeName(filePath)));
+#endif
Exiv2::AccessMode mode = image->checkMode(Exiv2::mdExif);
return (mode == Exiv2::amWrite || mode == Exiv2::amReadWrite);
@@ -510,7 +540,7 @@ bool KExiv2::canWriteExif(const TQString& filePath)
catch( Exiv2::Error &e )
{
std::string s(e.what());
- tqDebug("%s (Error #%i: %s)", "Cannot check Exif access mode using Exiv2 ", e.code(), s.c_str());
+ tqDebug("%s (Error #%i: %s)", "Cannot check Exif access mode using Exiv2 ", (int)e.code(), s.c_str());
}
return false;
@@ -520,8 +550,13 @@ bool KExiv2::canWriteIptc(const TQString& filePath)
{
try
{
+#if (EXIV2_TEST_VERSION(0,28,0))
+ Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open((const char*)
+ (TQFile::encodeName(filePath)));
+#else
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open((const char*)
(TQFile::encodeName(filePath)));
+#endif
Exiv2::AccessMode mode = image->checkMode(Exiv2::mdIptc);
return (mode == Exiv2::amWrite || mode == Exiv2::amReadWrite);
@@ -529,7 +564,7 @@ bool KExiv2::canWriteIptc(const TQString& filePath)
catch( Exiv2::Error &e )
{
std::string s(e.what());
- tqDebug("%s (Error #%i: %s)", "Cannot check Iptc access mode using Exiv2 ", e.code(), s.c_str());
+ tqDebug("%s (Error #%i: %s)", "Cannot check Iptc access mode using Exiv2 ", (int)e.code(), s.c_str());
}
return false;
@@ -584,7 +619,11 @@ TQSize KExiv2::getImageDimensions() const
try
{
+#if (EXIV2_TEST_VERSION(0,28,0))
+ int64_t width=-1, height=-1;
+#else
long width=-1, height=-1;
+#endif
// Try to get Exif.Photo tags
@@ -593,13 +632,25 @@ TQSize KExiv2::getImageDimensions() const
Exiv2::ExifData::iterator it = exifData.findKey(key);
if (it != exifData.end())
+ {
+#if (EXIV2_TEST_VERSION(0,28,0))
+ width = it->toInt64();
+#else
width = it->toLong();
+#endif
+ }
Exiv2::ExifKey key2("Exif.Photo.PixelYDimension");
Exiv2::ExifData::iterator it2 = exifData.findKey(key2);
if (it2 != exifData.end())
+ {
+#if (EXIV2_TEST_VERSION(0,28,0))
+ height = it2->toInt64();
+#else
height = it2->toLong();
+#endif
+ }
if (width != -1 && height != -1)
return TQSize(width, height);
@@ -613,13 +664,25 @@ TQSize KExiv2::getImageDimensions() const
Exiv2::ExifData::iterator it3 = exifData.findKey(key3);
if (it3 != exifData.end())
+ {
+#if (EXIV2_TEST_VERSION(0,28,0))
+ width = it3->toInt64();
+#else
width = it3->toLong();
+#endif
+ }
Exiv2::ExifKey key4("Exif.Image.ImageLength");
Exiv2::ExifData::iterator it4 = exifData.findKey(key4);
if (it4 != exifData.end())
+ {
+#if (EXIV2_TEST_VERSION(0,28,0))
+ height = it4->toInt64();
+#else
height = it4->toLong();
+#endif
+ }
if (width != -1 && height != -1)
return TQSize(width, height);
@@ -665,7 +728,11 @@ TQImage KExiv2::getExifThumbnail(bool fixOrientation) const
{
Exiv2::ExifThumbC thumb(d->exifMetadata);
Exiv2::DataBuf const c1 = thumb.copy();
+#if (EXIV2_TEST_VERSION(0,28,0))
+ thumbnail.loadFromData(c1.c_data(), c1.size());
+#else
thumbnail.loadFromData(c1.pData_, c1.size_);
+#endif
if (!thumbnail.isNull())
{
@@ -677,7 +744,11 @@ TQImage KExiv2::getExifThumbnail(bool fixOrientation) const
if (it != exifData.end())
{
TQWMatrix matrix;
+#if (EXIV2_TEST_VERSION(0,28,0))
+ int64_t orientation = it->toInt64();
+#else
long orientation = it->toLong();
+#endif
tqDebug("Exif Thumbnail Qt::Orientation: %i", (int)orientation);
switch (orientation)
@@ -777,7 +848,11 @@ KExiv2::ImageOrientation KExiv2::getImageOrientation() const
{
Exiv2::ExifData exifData(d->exifMetadata);
Exiv2::ExifData::iterator it;
+#if (EXIV2_TEST_VERSION(0,28,0))
+ int64_t orientation;
+#else
long orientation;
+#endif
ImageOrientation imageOrient = ORIENTATION_NORMAL;
// Because some camera set a wrong standard exif orientation tag,
@@ -792,7 +867,11 @@ KExiv2::ImageOrientation KExiv2::getImageOrientation() const
if (it != exifData.end())
{
+#if (EXIV2_TEST_VERSION(0,28,0))
+ orientation = it->toInt64();
+#else
orientation = it->toLong();
+#endif
tqDebug("Minolta Makernote Qt::Orientation: %i", (int)orientation);
switch(orientation)
{
@@ -811,7 +890,11 @@ KExiv2::ImageOrientation KExiv2::getImageOrientation() const
if (it != exifData.end())
{
+#if (EXIV2_TEST_VERSION(0,28,0))
+ orientation = it->toInt64();
+#else
orientation = it->toLong();
+#endif
tqDebug("Minolta Makernote Qt::Orientation: %i", (int)orientation);
switch(orientation)
{
@@ -833,7 +916,11 @@ KExiv2::ImageOrientation KExiv2::getImageOrientation() const
if (it != exifData.end())
{
+#if (EXIV2_TEST_VERSION(0,28,0))
+ orientation = it->toInt64();
+#else
orientation = it->toLong();
+#endif
tqDebug("Exif Qt::Orientation: %i", (int)orientation);
return (ImageOrientation)orientation;
}
@@ -1305,7 +1392,11 @@ bool KExiv2::getExifTagLong(const char* exifTagName, long &val) const
Exiv2::ExifData::iterator it = exifData.findKey(exifKey);
if (it != exifData.end())
{
+#if (EXIV2_TEST_VERSION(0,28,0))
+ val = (long)it->toInt64();
+#else
val = it->toLong();
+#endif
return true;
}
}
@@ -1829,7 +1920,11 @@ bool KExiv2::setGPSInfo(double altitude, double latitude, double longitude, bool
// Do all the easy constant ones first.
// GPSVersionID tag: standard says is should be four bytes: 02 00 00 00
// (and, must be present).
+#if (EXIV2_TEST_VERSION(0,28,0))
+ Exiv2::Value::UniquePtr value = Exiv2::Value::create(Exiv2::unsignedByte);
+#else
Exiv2::Value::AutoPtr value = Exiv2::Value::create(Exiv2::unsignedByte);
+#endif
value->read("2 0 0 0");
d->exifMetadata.add(Exiv2::ExifKey("Exif.GPSInfo.GPSVersionID"), value.get());
@@ -2097,7 +2192,11 @@ bool KExiv2::setImageKeywords(const TQStringList& oldKeywords, const TQStringLis
TQString key = *it;
key.truncate(64);
+#if (EXIV2_TEST_VERSION(0,28,0))
+ Exiv2::Value::UniquePtr val = Exiv2::Value::create(Exiv2::string);
+#else
Exiv2::Value::AutoPtr val = Exiv2::Value::create(Exiv2::string);
+#endif
val->read(key.latin1());
iptcData.add(iptcTag, val.get());
}
@@ -2180,7 +2279,11 @@ bool KExiv2::setImageSubjects(const TQStringList& oldSubjects, const TQStringLis
TQString key = *it;
key.truncate(236);
+#if (EXIV2_TEST_VERSION(0,28,0))
+ Exiv2::Value::UniquePtr val = Exiv2::Value::create(Exiv2::string);
+#else
Exiv2::Value::AutoPtr val = Exiv2::Value::create(Exiv2::string);
+#endif
val->read(key.latin1());
iptcData.add(iptcTag, val.get());
}
@@ -2264,7 +2367,11 @@ bool KExiv2::setImageSubCategories(const TQStringList& oldSubCategories, const T
TQString key = *it;
key.truncate(32);
+#if (EXIV2_TEST_VERSION(0,28,0))
+ Exiv2::Value::UniquePtr val = Exiv2::Value::create(Exiv2::string);
+#else
Exiv2::Value::AutoPtr val = Exiv2::Value::create(Exiv2::string);
+#endif
val->read(key.latin1());
iptcData.add(iptcTag, val.get());
}
diff --git a/libkexiv2/libkexiv2/kexiv2private.cpp b/libkexiv2/libkexiv2/kexiv2private.cpp
index f92776d..6377bb7 100644
--- a/libkexiv2/libkexiv2/kexiv2private.cpp
+++ b/libkexiv2/libkexiv2/kexiv2private.cpp
@@ -49,11 +49,19 @@ bool KExiv2Priv::setExif(Exiv2::DataBuf const data)
{
try
{
+#if (EXIV2_TEST_VERSION(0,28,0))
+ if (data.size() != 0)
+ {
+ Exiv2::ExifParser::decode(exifMetadata, data.c_data(), data.size());
+ return (!exifMetadata.empty());
+ }
+#else
if (data.size_ != 0)
{
Exiv2::ExifParser::decode(exifMetadata, data.pData_, data.size_);
return (!exifMetadata.empty());
}
+#endif
}
catch( Exiv2::Error &e )
{
@@ -70,11 +78,19 @@ bool KExiv2Priv::setIptc(Exiv2::DataBuf const data)
{
try
{
+#if (EXIV2_TEST_VERSION(0,28,0))
+ if (data.size() != 0)
+ {
+ Exiv2::IptcParser::decode(iptcMetadata, data.c_data(), data.size());
+ return (!iptcMetadata.empty());
+ }
+#else
if (data.size_ != 0)
{
Exiv2::IptcParser::decode(iptcMetadata, data.pData_, data.size_);
return (!iptcMetadata.empty());
}
+#endif
}
catch( Exiv2::Error &e )
{
@@ -90,7 +106,7 @@ bool KExiv2Priv::setIptc(Exiv2::DataBuf const data)
void KExiv2Priv::printExiv2ExceptionError(const TQString& msg, Exiv2::Error& e)
{
std::string s(e.what());
- tqDebug("%s (Error #%i: %s)", msg.ascii(), e.code(), s.c_str());
+ tqDebug("%s (Error #%i: %s)", msg.ascii(), (int)e.code(), s.c_str());
}
TQString KExiv2Priv::convertCommentValue(const Exiv2::Exifdatum &exifDatum)