KExiv2

kexiv2.h
Go to the documentation of this file.
1 
34 #ifndef KEXIV2_H
35 #define KEXIV2_H
36 
37 // QT includes
38 
39 #include <QByteArray>
40 #include <QString>
41 #include <QDateTime>
42 #include <QMap>
43 #include <QSharedDataPointer>
44 #include <QStringList>
45 #include <QVariant>
46 #include <QRegExp>
47 #include <QUrl>
48 #include <QImage>
49 
50 // Local includes
51 
52 #include "libkexiv2_export.h"
53 #include "kexiv2data.h"
54 
58 namespace KExiv2Iface
59 {
60 
66 class LIBKEXIV2_EXPORT KExiv2
67 {
68 
69 public:
70 
75  {
77  WRITETOIMAGEONLY = 0,
78 
80  WRITETOSIDECARONLY = 1,
81 
83  WRITETOSIDECARANDIMAGE = 2,
84 
86  WRITETOSIDECARONLY4READONLYFILES = 3
87  };
88 
92  {
93  WORKSPACE_UNSPECIFIED = 0,
94  WORKSPACE_SRGB = 1,
95  WORKSPACE_ADOBERGB = 2,
96  WORKSPACE_UNCALIBRATED = 65535
97  };
98 
102  {
103  ORIENTATION_UNSPECIFIED = 0,
104  ORIENTATION_NORMAL = 1,
105  ORIENTATION_HFLIP = 2,
106  ORIENTATION_ROT_180 = 3,
107  ORIENTATION_VFLIP = 4,
108  ORIENTATION_ROT_90_HFLIP = 5,
109  ORIENTATION_ROT_90 = 6,
110  ORIENTATION_ROT_90_VFLIP = 7,
111  ORIENTATION_ROT_270 = 8
112  };
113 
118  {
119  NormalTag = 0,
120  ArrayBagTag = 1,
121  StructureTag = 2,
122  ArrayLangTag = 3,
123  ArraySeqTag = 4
124  };
125 
129 
135 
142 
143 public:
144 
147  KExiv2();
148 
151  KExiv2(const KExiv2& metadata);
152 
155  KExiv2(const KExiv2Data& data);
156 
159  KExiv2(const QString& filePath);
160 
163  virtual ~KExiv2();
164 
167  KExiv2& operator=(const KExiv2& metadata);
168 
169 public:
170 
171  //-----------------------------------------------------------------
173 
174 
180  static bool initializeExiv2();
181 
187  static bool cleanupExiv2();
188 
191  static bool supportXmp();
192 
195  static bool supportMetadataWritting(const QString& typeMime);
196 
199  static QString Exiv2Version();
200 
203  static QString version();
204 
208  static QString sidecarFilePathForFile(const QString& path);
209 
212  static QString sidecarPath(const QString& path);
213 
216  static QUrl sidecarUrl(const QUrl& url);
217 
220  static QUrl sidecarUrl(const QString& path);
221 
224  static bool hasSidecar(const QString& path);
225 
227 
228  //-----------------------------------------------------------------
230 
231 
232  KExiv2Data data() const;
233  void setData(const KExiv2Data& data);
234 
238  bool loadFromData(const QByteArray& imgData) const;
239 
243  virtual bool load(const QString& filePath) const;
244 
248  bool save(const QString& filePath) const;
249 
253  bool applyChanges() const;
254 
257  bool isEmpty() const;
258 
261  void setFilePath(const QString& path);
262 
265  QString getFilePath() const;
266 
276  QSize getPixelSize() const;
277 
281  QString getMimeType() const;
282 
286  void setWriteRawFiles(const bool on);
287 
291  bool writeRawFiles() const;
292 
295  void setUseXMPSidecar4Reading(const bool on);
296 
299  bool useXMPSidecar4Reading() const;
300 
305  void setMetadataWritingMode(const int mode);
306 
311  int metadataWritingMode() const;
312 
316  void setUpdateFileTimeStamp(bool on);
317 
320  bool updateFileTimeStamp() const;
321 
323 
324  //-------------------------------------------------------------------
326 
327 
331  bool setImageProgramId(const QString& program, const QString& version) const;
332 
336  QSize getImageDimensions() const;
337 
341  bool setImageDimensions(const QSize& size, bool setProgramName=true) const;
342 
346  KExiv2::ImageOrientation getImageOrientation() const;
347 
351  bool setImageOrientation(ImageOrientation orientation, bool setProgramName=true) const;
352 
356  KExiv2::ImageColorWorkSpace getImageColorWorkSpace() const;
357 
361  bool setImageColorWorkSpace(ImageColorWorkSpace workspace, bool setProgramName=true) const;
362 
366  QDateTime getImageDateTime() const;
367 
371  bool setImageDateTime(const QDateTime& dateTime, bool setDateTimeDigitized=false,
372  bool setProgramName=true) const;
373 
378  QDateTime getDigitizationDateTime(bool fallbackToCreationTime=false) const;
379 
383  bool getImagePreview(QImage& preview) const;
384 
391  virtual bool setImagePreview(const QImage& preview, bool setProgramName=true) const;
392 
394 
395  //-----------------------------------------------------------------
397 
398 
401  static bool canWriteComment(const QString& filePath);
402 
405  bool hasComments() const;
406 
409  bool clearComments() const;
410 
415  QByteArray getComments() const;
416 
421  QString getCommentsDecoded() const;
422 
426  bool setComments(const QByteArray& data) const;
427 
432  static QString detectLanguageAlt(const QString& value, QString& lang);
433 
435 
436  //-----------------------------------------------------------------
438 
439 
442  TagsMap getStdExifTagsList() const;
443 
446  TagsMap getMakernoteTagsList() const;
447 
450  static bool canWriteExif(const QString& filePath);
451 
454  bool hasExif() const;
455 
458  bool clearExif() const;
459 
467  QByteArray getExifEncoded(bool addExifHeader=false) const;
468 
472  bool setExif(const QByteArray& data) const;
473 
478  QImage getExifThumbnail(bool fixOrientation) const;
479 
483  bool rotateExifQImage(QImage& image, ImageOrientation orientation) const;
484 
488  bool setExifThumbnail(const QImage& thumb, bool setProgramName=true) const;
489 
491  bool removeExifThumbnail() const;
492 
494  bool setTiffThumbnail(const QImage& thumb, bool setProgramName=true) const;
495 
499  QString getExifComment() const;
500 
504  bool setExifComment(const QString& comment, bool setProgramName=true) const;
505 
509  QString getExifTagString(const char* exifTagName, bool escapeCR=true) const;
510 
513  bool setExifTagString(const char* exifTagName, const QString& value, bool setProgramName=true) const;
514 
517  bool getExifTagLong(const char* exifTagName, long &val) const;
518 
521  bool getExifTagLong(const char* exifTagName, long &val, int component) const;
522 
525  bool setExifTagLong(const char* exifTagName, long val, bool setProgramName=true) const;
526 
531  bool getExifTagRational(const char* exifTagName, long int& num, long int& den, int component=0) const;
532 
537  bool setExifTagRational(const char* exifTagName, long int num, long int den, bool setProgramName=true) const;
538 
542  QByteArray getExifTagData(const char* exifTagName) const;
543 
546  bool setExifTagData(const char* exifTagName, const QByteArray& data, bool setProgramName=true) const;
547 
556  QVariant getExifTagVariant(const char* exifTagName, bool rationalAsListOfInts=true, bool escapeCR=true, int component=0) const;
557 
564  bool setExifTagVariant(const char* exifTagName, const QVariant& data,
565  bool rationalWantSmallDenominator=true, bool setProgramName=true) const;
566 
570  bool removeExifTag(const char* exifTagName, bool setProgramName=true) const;
571 
574  QString getExifTagTitle(const char* exifTagName);
575 
578  QString getExifTagDescription(const char* exifTagName);
579 
585  QString createExifUserStringFromValue(const char* exifTagName, const QVariant& val, bool escapeCR=true);
586 
607  KExiv2::MetaDataMap getExifTagsDataList(const QStringList& exifKeysFilter=QStringList(), bool invertSelection=false) const;
608 
610 
611  //-------------------------------------------------------------
613 
614 
617  KExiv2::TagsMap getIptcTagsList() const;
618 
621  static bool canWriteIptc(const QString& filePath);
622 
625  bool hasIptc() const;
626 
629  bool clearIptc() const;
630 
635  QByteArray getIptc(bool addIrbHeader=false) const;
636 
640  bool setIptc(const QByteArray& data) const;
641 
645  QString getIptcTagString(const char* iptcTagName, bool escapeCR=true) const;
646 
649  bool setIptcTagString(const char* iptcTagName, const QString& value, bool setProgramName=true) const;
650 
658  QStringList getIptcTagsStringList(const char* iptcTagName, bool escapeCR=true) const;
659 
663  bool setIptcTagsStringList(const char* iptcTagName, int maxSize,
664  const QStringList& oldValues, const QStringList& newValues,
665  bool setProgramName=true) const;
666 
670  QByteArray getIptcTagData(const char* iptcTagName) const;
671 
674  bool setIptcTagData(const char* iptcTagName, const QByteArray& data, bool setProgramName=true) const;
675 
679  bool removeIptcTag(const char* iptcTagName, bool setProgramName=true) const;
680 
683  QString getIptcTagTitle(const char* iptcTagName);
684 
687  QString getIptcTagDescription(const char* iptcTagName);
688 
707  KExiv2::MetaDataMap getIptcTagsDataList(const QStringList& iptcKeysFilter=QStringList(), bool invertSelection=false) const;
708 
711  QStringList getIptcKeywords() const;
712 
718  bool setIptcKeywords(const QStringList& oldKeywords, const QStringList& newKeywords,
719  bool setProgramName=true) const;
720 
723  QStringList getIptcSubjects() const;
724 
730  bool setIptcSubjects(const QStringList& oldSubjects, const QStringList& newSubjects,
731  bool setProgramName=true) const;
732 
736  QStringList getIptcSubCategories() const;
737 
743  bool setIptcSubCategories(const QStringList& oldSubCategories, const QStringList& newSubCategories,
744  bool setProgramName=true) const;
745 
747 
748  //------------------------------------------------------------
750 
751 
754  KExiv2::TagsMap getXmpTagsList() const;
755 
758  static bool canWriteXmp(const QString& filePath);
759 
762  bool hasXmp() const;
763 
766  bool clearXmp() const;
767 
771  QByteArray getXmp() const;
772 
776  bool setXmp(const QByteArray& data) const;
777 
781  QString getXmpTagString(const char* xmpTagName, bool escapeCR=true) const;
782 
785  bool setXmpTagString(const char* xmpTagName, const QString& value,
786  bool setProgramName=true) const;
787 
792  bool setXmpTagString(const char* xmpTagName, const QString& value,
793  XmpTagType type,bool setProgramName=true) const;
794 
797  QString getXmpTagTitle(const char* xmpTagName);
798 
801  QString getXmpTagDescription(const char* xmpTagName);
802 
821  KExiv2::MetaDataMap getXmpTagsDataList(const QStringList& xmpKeysFilter=QStringList(), bool invertSelection=false) const;
822 
828  KExiv2::AltLangMap getXmpTagStringListLangAlt(const char* xmpTagName, bool escapeCR=true) const;
829 
834  bool setXmpTagStringListLangAlt(const char* xmpTagName, const KExiv2::AltLangMap& values,
835  bool setProgramName) const;
836 
842  QString getXmpTagStringLangAlt(const char* xmpTagName, const QString& langAlt, bool escapeCR) const;
843 
849  bool setXmpTagStringLangAlt(const char* xmpTagName, const QString& value,
850  const QString& langAlt, bool setProgramName=true) const;
851 
855  QStringList getXmpTagStringSeq(const char* xmpTagName, bool escapeCR=true) const;
856 
860  bool setXmpTagStringSeq(const char* xmpTagName, const QStringList& seq,
861  bool setProgramName=true) const;
862 
866  QStringList getXmpTagStringBag(const char* xmpTagName, bool escapeCR) const;
867 
871  bool setXmpTagStringBag(const char* xmpTagName, const QStringList& bag,
872  bool setProgramName=true) const;
873 
879  bool addToXmpTagStringBag(const char* xmpTagName, const QStringList& entriesToAdd,
880  bool setProgramName) const;
881 
886  bool removeFromXmpTagStringBag(const char* xmpTagName, const QStringList& entriesToRemove,
887  bool setProgramName) const;
888 
899  QVariant getXmpTagVariant(const char* xmpTagName, bool rationalAsListOfInts=true, bool stringEscapeCR=true) const;
900 
903  QStringList getXmpKeywords() const;
904 
910  bool setXmpKeywords(const QStringList& newKeywords, bool setProgramName=true) const;
911 
915  bool removeXmpKeywords(const QStringList& keywordsToRemove, bool setProgramName=true);
916 
919  QStringList getXmpSubjects() const;
920 
926  bool setXmpSubjects(const QStringList& newSubjects, bool setProgramName=true) const;
927 
931  bool removeXmpSubjects(const QStringList& subjectsToRemove, bool setProgramName=true);
932 
936  QStringList getXmpSubCategories() const;
937 
943  bool setXmpSubCategories(const QStringList& newSubCategories, bool setProgramName=true) const;
944 
948  bool removeXmpSubCategories(const QStringList& categoriesToRemove, bool setProgramName=true);
949 
953  bool removeXmpTag(const char* xmpTagName, bool setProgramName=true) const;
954 
955 
962  static bool registerXmpNameSpace(const QString& uri, const QString& prefix);
963 
965  static bool unregisterXmpNameSpace(const QString& uri);
966 
968 
969  //------------------------------------------------------------
971 
972 
975  bool initializeGPSInfo(const bool setProgramName);
976 
979  bool getGPSInfo(double& altitude, double& latitude, double& longitude) const;
980 
984  QString getGPSLatitudeString() const;
985  QString getGPSLongitudeString() const;
986 
991  bool getGPSLatitudeNumber(double* const latitude) const;
992  bool getGPSLongitudeNumber(double* const longitude) const;
993 
996  bool getGPSAltitude(double* const altitude) const;
997 
1001  bool setGPSInfo(const double altitude, const double latitude, const double longitude, const bool setProgramName=true);
1002 
1006  bool setGPSInfo(const double* const altitude, const double latitude, const double longitude, const bool setProgramName=true);
1007 
1011  bool setGPSInfo(const double altitude, const QString &latitude, const QString &longitude, const bool setProgramName=true);
1012 
1016  bool removeGPSInfo(const bool setProgramName=true);
1017 
1023  static void convertToRational(const double number, long int* const numerator,
1024  long int* const denominator, const int rounding);
1025 
1033  static void convertToRationalSmallDenominator(const double number, long int* const numerator,
1034  long int* const denominator);
1035 
1039  static QString convertToGPSCoordinateString(const long int numeratorDegrees, const long int denominatorDegrees,
1040  const long int numeratorMinutes, const long int denominatorMinutes,
1041  const long int numeratorSeconds, long int denominatorSeconds,
1042  const char directionReference);
1043 
1047  static QString convertToGPSCoordinateString(const bool isLatitude, double coordinate);
1048 
1053  static bool convertFromGPSCoordinateString(const QString& coordinate,
1054  long int* const numeratorDegrees, long int* const denominatorDegrees,
1055  long int* const numeratorMinutes, long int* const denominatorMinutes,
1056  long int* const numeratorSeconds, long int* const denominatorSeconds,
1057  char* const directionReference);
1058 
1063  static bool convertFromGPSCoordinateString(const QString& gpsString, double* const coordinate);
1064 
1068  static bool convertToUserPresentableNumbers(const QString& coordinate,
1069  int* const degrees, int* const minutes,
1070  double* const seconds, char* const directionReference);
1071 
1077  static void convertToUserPresentableNumbers(const bool isLatitude, double coordinate,
1078  int* const degrees, int* const minutes,
1079  double* const seconds, char* const directionReference);
1080 
1082 
1083 protected:
1084 
1089  virtual bool setProgramId(bool on=true) const;
1090 
1091 private:
1092 
1095  class Private;
1096  Private* const d;
1097 
1098  friend class KExiv2Previews;
1099 };
1100 
1101 } // NameSpace KExiv2Iface
1102 
1103 #endif /* KEXIV2_H */
===========================================================This file is a part of KDE project ...
KExiv2Iface.
Definition: kexiv2.cpp:36
QMap< QString, QString > AltLangMap
A map used to store a list of Alternative Language values.
Definition: kexiv2.h:134
ImageColorWorkSpace
The image color workspace values given by Exif metadata.
Definition: kexiv2.h:91
ImageOrientation
The image orientation values given by Exif metadata.
Definition: kexiv2.h:101
XmpTagType
Xmp tag types, used by setXmpTag, only first three types are used.
Definition: kexiv2.h:117
KExiv2.
Definition: kexiv2.h:66
QMap< QString, QString > MetaDataMap
A map used to store Tags Key and Tags Value.
Definition: kexiv2.h:128
QMap< QString, QStringList > TagsMap
A map used to store Tags Key and a list of Tags properties :
Definition: kexiv2.h:141
MetadataWritingMode
The image metadata writing mode, between image file metadata and XMP sidecar file, depending on the context.
Definition: kexiv2.h:74
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Nov 25 2020 22:35:16 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.