File indexing completed on 2025-01-26 04:25:03

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 
0003 /*
0004     Copyright (C) 2012-15  Vishesh Handa <vhanda@kde.org>
0005 
0006     This library is free software; you can redistribute it and/or
0007     modify it under the terms of the GNU Lesser General Public
0008     License as published by the Free Software Foundation; either
0009     version 2.1 of the License, or (at your option) any later version.
0010 
0011     This library is distributed in the hope that it will be useful,
0012     but WITHOUT ANY WARRANTY; without even the implied warranty of
0013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014     Lesser General Public License for more details.
0015 
0016     You should have received a copy of the GNU Lesser General Public
0017     License along with this library; if not, write to the Free Software
0018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0019 */
0020 
0021 #ifndef EXIV2EXTRACTOR_H
0022 #define EXIV2EXTRACTOR_H
0023 
0024 #include <exiv2/exiv2.hpp>
0025 
0026 #include <QString>
0027 #include <QVariant>
0028 #include <QUrl>
0029 
0030 #include "imagetools_export.h"
0031 
0032 typedef QMap<QString, QString> MetaDataMap;
0033 typedef QPair<double, double> Coordinates;
0034 
0035 class City;
0036 class IMAGETOOLS_EXPORT Exiv2Extractor : public QObject
0037 {
0038 public:
0039     Exiv2Extractor(const QUrl &url, QObject * parent = nullptr);
0040    explicit Exiv2Extractor(QObject * parent = nullptr);
0041     
0042     void setUrl(const QUrl &url);
0043     
0044     Coordinates extractGPS() const;
0045 
0046     bool error() const;
0047     
0048     QString getExifTagString (const char *exifTagName, bool escapeCR=true) const;
0049     QByteArray getExifTagData (const char *exifTagName) const;
0050     QVariant getExifTagVariant (const char *exifTagName, bool rationalAsListOfInts=true, bool escapeCR=true, int component=0) const;
0051     MetaDataMap getExifTagsDataList( const QStringList & exifKeysFilter = QStringList(), bool invertSelection = false ) const;
0052     QString getExifComment() const;
0053     
0054     bool writeTag(const char *tagName, const QVariant &value);
0055     bool removeTag(const char *tagName);
0056     
0057     QString GPSString() const;
0058     QString cityId() const;
0059     City *city() const;
0060     
0061 private:
0062     double fetchGpsDouble(const char *name) const;
0063 
0064     bool m_error;
0065     
0066     QUrl m_url;
0067        
0068     #if EXIV2_TEST_VERSION(0, 27, 99)
0069     Exiv2::Image::UniquePtr m_image;
0070     #else
0071     Exiv2::Image::AutoPtr m_image;
0072     #endif
0073 
0074     Exiv2::ExifData & exifData() const;
0075 };
0076 
0077 #endif // EXIV2EXTRACTOR_H