|
|
|
@ -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.
|
|
|
|
@ -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());
|
|
|
|
|
}
|
|
|
|
|