File indexing completed on 2024-05-19 15:28:45

0001 // SPDX-FileCopyrightText: 2003-2010 Jesper K. Pedersen <blackie@kde.org>
0002 // SPDX-FileCopyrightText: 2021 Johannes Zarl-Zierl <johannes@zarl-zierl.at>
0003 //
0004 // SPDX-License-Identifier: GPL-2.0-or-later
0005 
0006 #ifndef EXIF_INFO_H
0007 #define EXIF_INFO_H
0008 #include <kpabase/StringSet.h>
0009 
0010 #include <exiv2/exif.hpp>
0011 #include <exiv2/iptc.hpp>
0012 #include <qmap.h>
0013 #include <qstringlist.h>
0014 
0015 namespace DB
0016 {
0017 class FileName;
0018 }
0019 
0020 namespace Exif
0021 {
0022 
0023 using Utilities::StringSet;
0024 
0025 struct Metadata {
0026     Exiv2::ExifData exif;
0027     Exiv2::IptcData iptc;
0028     std::string comment;
0029 };
0030 
0031 class Info
0032 {
0033 public:
0034     Info();
0035     static Info *instance();
0036     QMap<QString, QStringList> info(const DB::FileName &fileName, StringSet wantedKeys, bool returnFullExifName, const QString &charset);
0037     QMap<QString, QStringList> infoForViewer(const DB::FileName &fileName, const QString &charset);
0038     QMap<QString, QStringList> infoForDialog(const DB::FileName &fileName, const QString &charset);
0039     StringSet availableKeys();
0040     StringSet standardKeys();
0041     Metadata metadata(const DB::FileName &fileName);
0042 
0043 protected:
0044     DB::FileName exifInfoFile(const DB::FileName &fileName);
0045 
0046 private:
0047     static Info *s_instance;
0048     StringSet m_keys;
0049 };
0050 
0051 /**
0052      * @brief Writes the exif information from one file to another.
0053      * The given description is overwrites the exif description field of the destination file.
0054      * @param srcName the image file in the database
0055      * @param destName the destination image file
0056      * @param imageDescription the image description text (usually DB::ImageInfo::description())
0057      */
0058 void writeExifInfoToFile(const DB::FileName &srcName, const QString &destName, const QString &imageDescription);
0059 
0060 }
0061 
0062 #endif /* EXIF_INFO_H */
0063 
0064 // vi:expandtab:tabstop=4 shiftwidth=4: