|
|
|
@ -10,7 +10,7 @@
|
|
|
|
|
* Copyright (C) 2006-2009 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
|
|
|
|
|
*
|
|
|
|
|
* NOTE: Do not use kdDebug() in this implementation because
|
|
|
|
|
* it will be multithreaded. Use qDebug() instead.
|
|
|
|
|
* it will be multithreaded. Use tqDebug() instead.
|
|
|
|
|
* See B.K.O #133026 for details.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it
|
|
|
|
@ -199,7 +199,7 @@ TQByteArray KExiv2::getExif() const
|
|
|
|
|
catch( Exiv2::Error &e )
|
|
|
|
|
{
|
|
|
|
|
if (!d->filePath.isEmpty())
|
|
|
|
|
qDebug ("From file %s", d->filePath.ascii());
|
|
|
|
|
tqDebug ("From file %s", d->filePath.ascii());
|
|
|
|
|
|
|
|
|
|
d->printExiv2ExceptionError("Cannot get Exif data using Exiv2 ", e);
|
|
|
|
|
}
|
|
|
|
@ -221,7 +221,7 @@ TQByteArray KExiv2::getIptc(bool addIrbHeader) const
|
|
|
|
|
#if (EXIV2_TEST_VERSION(0,10,0))
|
|
|
|
|
c2 = Exiv2::Photoshop::setIptcIrb(0, 0, iptc);
|
|
|
|
|
#else
|
|
|
|
|
qDebug("Exiv2 version is to old. Cannot add Irb header to IPTC metadata");
|
|
|
|
|
tqDebug("Exiv2 version is to old. Cannot add Irb header to IPTC metadata");
|
|
|
|
|
return TQByteArray();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
@ -243,7 +243,7 @@ TQByteArray KExiv2::getIptc(bool addIrbHeader) const
|
|
|
|
|
catch( Exiv2::Error &e )
|
|
|
|
|
{
|
|
|
|
|
if (!d->filePath.isEmpty())
|
|
|
|
|
qDebug ("From file %s", d->filePath.ascii());
|
|
|
|
|
tqDebug ("From file %s", d->filePath.ascii());
|
|
|
|
|
|
|
|
|
|
d->printExiv2ExceptionError("Cannot get Iptc data using Exiv2 ",e);
|
|
|
|
|
}
|
|
|
|
@ -277,7 +277,7 @@ bool KExiv2::setExif(const TQByteArray& data)
|
|
|
|
|
catch( Exiv2::Error &e )
|
|
|
|
|
{
|
|
|
|
|
if (!d->filePath.isEmpty())
|
|
|
|
|
qDebug ("From file %s", d->filePath.ascii());
|
|
|
|
|
tqDebug ("From file %s", d->filePath.ascii());
|
|
|
|
|
|
|
|
|
|
d->printExiv2ExceptionError("Cannot set Exif data using Exiv2 ", e);
|
|
|
|
|
}
|
|
|
|
@ -305,7 +305,7 @@ bool KExiv2::setIptc(const TQByteArray& data)
|
|
|
|
|
catch( Exiv2::Error &e )
|
|
|
|
|
{
|
|
|
|
|
if (!d->filePath.isEmpty())
|
|
|
|
|
qDebug ("From file %s", d->filePath.ascii());
|
|
|
|
|
tqDebug ("From file %s", d->filePath.ascii());
|
|
|
|
|
|
|
|
|
|
d->printExiv2ExceptionError("Cannot set Iptc data using Exiv2 ", e);
|
|
|
|
|
}
|
|
|
|
@ -352,7 +352,7 @@ bool KExiv2::load(const TQString& filePath)
|
|
|
|
|
TQFileInfo finfo(filePath);
|
|
|
|
|
if (filePath.isEmpty() || !finfo.isReadable())
|
|
|
|
|
{
|
|
|
|
|
qDebug("File '%s' is not readable.", finfo.fileName().ascii());
|
|
|
|
|
tqDebug("File '%s' is not readable.", finfo.fileName().ascii());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -396,12 +396,12 @@ bool KExiv2::save(const TQString& filePath)
|
|
|
|
|
TQFileInfo dinfo(finfo.dirPath());
|
|
|
|
|
if (!finfo.isWritable())
|
|
|
|
|
{
|
|
|
|
|
qDebug("File '%s' is read-only. Metadata not saved.", finfo.fileName().ascii());
|
|
|
|
|
tqDebug("File '%s' is read-only. Metadata not saved.", finfo.fileName().ascii());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!dinfo.isWritable())
|
|
|
|
|
{
|
|
|
|
|
qDebug("Dir '%s' is read-only. Metadata not saved.", dinfo.filePath().ascii());
|
|
|
|
|
tqDebug("Dir '%s' is read-only. Metadata not saved.", dinfo.filePath().ascii());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -410,7 +410,7 @@ bool KExiv2::save(const TQString& filePath)
|
|
|
|
|
TQString rawTiffBased("dng nef pef 3fr arw cr2 dcr erf k25 kdc mos orf raw sr2 srf");
|
|
|
|
|
if (rawTiffBased.contains(finfo.extension(false).lower()))
|
|
|
|
|
{
|
|
|
|
|
qDebug("'%s' is TIFF based RAW file and writing mode is disable with this libkexiv2 version. Metadata not saved.",
|
|
|
|
|
tqDebug("'%s' is TIFF based RAW file and writing mode is disable with this libkexiv2 version. Metadata not saved.",
|
|
|
|
|
finfo.fileName().ascii());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -541,7 +541,7 @@ bool KExiv2::canWriteComment(const TQString& filePath)
|
|
|
|
|
catch( Exiv2::Error &e )
|
|
|
|
|
{
|
|
|
|
|
std::string s(e.what());
|
|
|
|
|
qDebug("%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 ", e.code(), s.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
@ -560,7 +560,7 @@ bool KExiv2::canWriteExif(const TQString& filePath)
|
|
|
|
|
catch( Exiv2::Error &e )
|
|
|
|
|
{
|
|
|
|
|
std::string s(e.what());
|
|
|
|
|
qDebug("%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 ", e.code(), s.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
@ -579,7 +579,7 @@ bool KExiv2::canWriteIptc(const TQString& filePath)
|
|
|
|
|
catch( Exiv2::Error &e )
|
|
|
|
|
{
|
|
|
|
|
std::string s(e.what());
|
|
|
|
|
qDebug("%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 ", e.code(), s.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
@ -734,7 +734,7 @@ TQImage KExiv2::getExifThumbnail(bool fixOrientation) const
|
|
|
|
|
{
|
|
|
|
|
TQWMatrix matrix;
|
|
|
|
|
long orientation = it->toLong();
|
|
|
|
|
qDebug("Exif Thumbnail Qt::Orientation: %i", (int)orientation);
|
|
|
|
|
tqDebug("Exif Thumbnail Qt::Orientation: %i", (int)orientation);
|
|
|
|
|
|
|
|
|
|
switch (orientation)
|
|
|
|
|
{
|
|
|
|
@ -858,7 +858,7 @@ KExiv2::ImageOrientation KExiv2::getImageOrientation() const
|
|
|
|
|
if (it != exifData.end())
|
|
|
|
|
{
|
|
|
|
|
orientation = it->toLong();
|
|
|
|
|
qDebug("Minolta Makernote Qt::Orientation: %i", (int)orientation);
|
|
|
|
|
tqDebug("Minolta Makernote Qt::Orientation: %i", (int)orientation);
|
|
|
|
|
switch(orientation)
|
|
|
|
|
{
|
|
|
|
|
case 76:
|
|
|
|
@ -877,7 +877,7 @@ KExiv2::ImageOrientation KExiv2::getImageOrientation() const
|
|
|
|
|
if (it != exifData.end())
|
|
|
|
|
{
|
|
|
|
|
orientation = it->toLong();
|
|
|
|
|
qDebug("Minolta Makernote Qt::Orientation: %i", (int)orientation);
|
|
|
|
|
tqDebug("Minolta Makernote Qt::Orientation: %i", (int)orientation);
|
|
|
|
|
switch(orientation)
|
|
|
|
|
{
|
|
|
|
|
case 76:
|
|
|
|
@ -899,7 +899,7 @@ KExiv2::ImageOrientation KExiv2::getImageOrientation() const
|
|
|
|
|
if (it != exifData.end())
|
|
|
|
|
{
|
|
|
|
|
orientation = it->toLong();
|
|
|
|
|
qDebug("Exif Qt::Orientation: %i", (int)orientation);
|
|
|
|
|
tqDebug("Exif Qt::Orientation: %i", (int)orientation);
|
|
|
|
|
return (ImageOrientation)orientation;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -936,12 +936,12 @@ bool KExiv2::setImageOrientation(ImageOrientation orientation, bool setProgramNa
|
|
|
|
|
{
|
|
|
|
|
if (orientation < ORIENTATION_UNSPECIFIED || orientation > ORIENTATION_ROT_270)
|
|
|
|
|
{
|
|
|
|
|
qDebug("Exif orientation tag value is not correct!");
|
|
|
|
|
tqDebug("Exif orientation tag value is not correct!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
d->exifMetadata["Exif.Image.Orientation"] = static_cast<uint16_t>(orientation);
|
|
|
|
|
qDebug("Exif orientation tag set to: %i", (int)orientation);
|
|
|
|
|
tqDebug("Exif orientation tag set to: %i", (int)orientation);
|
|
|
|
|
|
|
|
|
|
// -- Minolta Cameras ----------------------------------
|
|
|
|
|
|
|
|
|
@ -957,7 +957,7 @@ bool KExiv2::setImageOrientation(ImageOrientation orientation, bool setProgramNa
|
|
|
|
|
if (it != d->exifMetadata.end())
|
|
|
|
|
{
|
|
|
|
|
d->exifMetadata.erase(it);
|
|
|
|
|
qDebug("Removing Exif.MinoltaCs7D.Rotation tag");
|
|
|
|
|
tqDebug("Removing Exif.MinoltaCs7D.Rotation tag");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Exiv2::ExifKey minoltaKey2("Exif.MinoltaCs5D.Rotation");
|
|
|
|
@ -965,7 +965,7 @@ bool KExiv2::setImageOrientation(ImageOrientation orientation, bool setProgramNa
|
|
|
|
|
if (it != d->exifMetadata.end())
|
|
|
|
|
{
|
|
|
|
|
d->exifMetadata.erase(it);
|
|
|
|
|
qDebug("Removing Exif.MinoltaCs5D.Rotation tag");
|
|
|
|
|
tqDebug("Removing Exif.MinoltaCs5D.Rotation tag");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1034,7 +1034,7 @@ bool KExiv2::setImageColorWorkSpace(ImageColorWorkSpace workspace, bool setProgr
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
d->exifMetadata["Exif.Photo.ColorSpace"] = static_cast<uint16_t>(workspace);
|
|
|
|
|
qDebug("Exif color workspace tag set to: %i", (int)workspace);
|
|
|
|
|
tqDebug("Exif color workspace tag set to: %i", (int)workspace);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch( Exiv2::Error &e )
|
|
|
|
@ -1065,7 +1065,7 @@ TQDateTime KExiv2::getImageDateTime() const
|
|
|
|
|
|
|
|
|
|
if (dateTime.isValid())
|
|
|
|
|
{
|
|
|
|
|
// qDebug("DateTime (Exif original): %s", dateTime.toString().ascii());
|
|
|
|
|
// tqDebug("DateTime (Exif original): %s", dateTime.toString().ascii());
|
|
|
|
|
return dateTime;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1081,7 +1081,7 @@ TQDateTime KExiv2::getImageDateTime() const
|
|
|
|
|
|
|
|
|
|
if (dateTime.isValid())
|
|
|
|
|
{
|
|
|
|
|
// qDebug("DateTime (Exif digitalized): %s", dateTime.toString().ascii());
|
|
|
|
|
// tqDebug("DateTime (Exif digitalized): %s", dateTime.toString().ascii());
|
|
|
|
|
return dateTime;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1097,7 +1097,7 @@ TQDateTime KExiv2::getImageDateTime() const
|
|
|
|
|
|
|
|
|
|
if (dateTime.isValid())
|
|
|
|
|
{
|
|
|
|
|
// qDebug("DateTime (Exif standard): %s", dateTime.toString().ascii());
|
|
|
|
|
// tqDebug("DateTime (Exif standard): %s", dateTime.toString().ascii());
|
|
|
|
|
return dateTime;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1130,7 +1130,7 @@ TQDateTime KExiv2::getImageDateTime() const
|
|
|
|
|
|
|
|
|
|
if (dateTime.isValid())
|
|
|
|
|
{
|
|
|
|
|
// qDebug("Date (IPTC created): %s", dateTime.toString().ascii());
|
|
|
|
|
// tqDebug("Date (IPTC created): %s", dateTime.toString().ascii());
|
|
|
|
|
return dateTime;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1158,7 +1158,7 @@ TQDateTime KExiv2::getImageDateTime() const
|
|
|
|
|
|
|
|
|
|
if (dateTime.isValid())
|
|
|
|
|
{
|
|
|
|
|
//qDebug("Date (IPTC digitalized): %s", dateTime.toString().ascii());
|
|
|
|
|
//tqDebug("Date (IPTC digitalized): %s", dateTime.toString().ascii());
|
|
|
|
|
return dateTime;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1249,7 +1249,7 @@ bool KExiv2::setImagePreview(const TQImage& preview, bool setProgramName)
|
|
|
|
|
|
|
|
|
|
// A little bit compressed preview jpeg image to limit IPTC size.
|
|
|
|
|
preview.save(&buffer, "JPEG");
|
|
|
|
|
qDebug("JPEG image preview size: (%i x %i) pixels - %i bytes",
|
|
|
|
|
tqDebug("JPEG image preview size: (%i x %i) pixels - %i bytes",
|
|
|
|
|
preview.width(), preview.height(), (int)data.size());
|
|
|
|
|
|
|
|
|
|
Exiv2::DataValue val;
|
|
|
|
@ -2151,7 +2151,7 @@ bool KExiv2::setImageKeywords(const TQStringList& oldKeywords, const TQStringLis
|
|
|
|
|
TQStringList oldkeys = oldKeywords;
|
|
|
|
|
TQStringList newkeys = newKeywords;
|
|
|
|
|
|
|
|
|
|
qDebug("%s ==> Keywords: %s", d->filePath.ascii(), newkeys.join(",").ascii());
|
|
|
|
|
tqDebug("%s ==> Keywords: %s", d->filePath.ascii(), newkeys.join(",").ascii());
|
|
|
|
|
|
|
|
|
|
// Remove all old keywords.
|
|
|
|
|
Exiv2::IptcData iptcData(d->iptcMetadata);
|
|
|
|
|