File indexing completed on 2024-05-12 04:46:37
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 #pragma once 0022 0023 #include <exiv2/exiv2.hpp> 0024 0025 #include <QString> 0026 #include <QVariant> 0027 #include <QUrl> 0028 0029 #include "imagetools_export.h" 0030 0031 typedef QMap<QString, QString> MetaDataMap; 0032 typedef QPair<double, double> Coordinates; 0033 0034 class City; 0035 0036 /** 0037 * @brief Image metadata extractor. 0038 */ 0039 class IMAGETOOLS_EXPORT Exiv2Extractor : public QObject 0040 { 0041 public: 0042 Exiv2Extractor(const QUrl &url, QObject * parent = nullptr); 0043 explicit Exiv2Extractor(QObject * parent = nullptr); 0044 0045 void setUrl(const QUrl &url); 0046 0047 Coordinates extractGPS() const; 0048 0049 bool error() const; 0050 0051 QString getExifTagString (const char *exifTagName, bool escapeCR=true) const; 0052 QByteArray getExifTagData (const char *exifTagName) const; 0053 QVariant getExifTagVariant (const char *exifTagName, bool rationalAsListOfInts=true, bool escapeCR=true, int component=0) const; 0054 MetaDataMap getExifTagsDataList( const QStringList & exifKeysFilter = QStringList(), bool invertSelection = false ) const; 0055 QString getExifComment() const; 0056 0057 bool writeTag(const char *tagName, const QVariant &value); 0058 bool removeTag(const char *tagName); 0059 0060 QString GPSString() const; 0061 QString cityId() const; 0062 City city() const; 0063 0064 private: 0065 double fetchGpsDouble(const char *name) const; 0066 0067 bool m_error; 0068 0069 QUrl m_url; 0070 0071 #if EXIV2_TEST_VERSION(0, 27, 99) 0072 Exiv2::Image::UniquePtr m_image; 0073 #else 0074 Exiv2::Image::AutoPtr m_image; 0075 #endif 0076 0077 Exiv2::ExifData & exifData() const; 0078 };