git repos / SagoImageBrowser

blame: src/exifreader.h

normal view · raw

14cf904f Poul Sander 2026-06-22 18:18 1
/*
14cf904f Poul Sander 2026-06-22 18:18 2
MIT License
14cf904f Poul Sander 2026-06-22 18:18 3
14cf904f Poul Sander 2026-06-22 18:18 4
Copyright (c) 2026 Poul Sander
14cf904f Poul Sander 2026-06-22 18:18 5
14cf904f Poul Sander 2026-06-22 18:18 6
Permission is hereby granted, free of charge, to any person obtaining a copy
14cf904f Poul Sander 2026-06-22 18:18 7
of this software and associated documentation files (the "Software"), to deal
14cf904f Poul Sander 2026-06-22 18:18 8
in the Software without restriction, including without limitation the rights
14cf904f Poul Sander 2026-06-22 18:18 9
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14cf904f Poul Sander 2026-06-22 18:18 10
copies of the Software, and to permit persons to whom the Software is
14cf904f Poul Sander 2026-06-22 18:18 11
furnished to do so, subject to the following conditions:
14cf904f Poul Sander 2026-06-22 18:18 12
14cf904f Poul Sander 2026-06-22 18:18 13
The above copyright notice and this permission notice shall be included in all
14cf904f Poul Sander 2026-06-22 18:18 14
copies or substantial portions of the Software.
14cf904f Poul Sander 2026-06-22 18:18 15
14cf904f Poul Sander 2026-06-22 18:18 16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14cf904f Poul Sander 2026-06-22 18:18 17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14cf904f Poul Sander 2026-06-22 18:18 18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14cf904f Poul Sander 2026-06-22 18:18 19
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14cf904f Poul Sander 2026-06-22 18:18 20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
14cf904f Poul Sander 2026-06-22 18:18 21
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
14cf904f Poul Sander 2026-06-22 18:18 22
SOFTWARE.
14cf904f Poul Sander 2026-06-22 18:18 23
14cf904f Poul Sander 2026-06-22 18:18 24
*/
53fdab93 Poul Sander 2026-05-18 18:45 25
#pragma once
53fdab93 Poul Sander 2026-05-18 18:45 26
80a9926d Poul Sander 2026-05-19 20:28 27
#include <QByteArray>
53fdab93 Poul Sander 2026-05-18 18:45 28
#include <QString>
53fdab93 Poul Sander 2026-05-18 18:45 29
#include <QList>
53fdab93 Poul Sander 2026-05-18 18:45 30
#include <QPair>
53fdab93 Poul Sander 2026-05-18 18:45 31
53fdab93 Poul Sander 2026-05-18 18:45 32
struct ExifData {
beb4a823 Poul Sander 2026-05-19 21:53 33
    QString captionAbstract;  // IPTC Caption-Abstract (Iptc.Application2.Caption)
beb4a823 Poul Sander 2026-05-19 21:53 34
    QString description;      // Exif.Image.ImageDescription
53fdab93 Poul Sander 2026-05-18 18:45 35
    QString dateTime;
53fdab93 Poul Sander 2026-05-18 18:45 36
    QString make;
53fdab93 Poul Sander 2026-05-18 18:45 37
    QString model;
53fdab93 Poul Sander 2026-05-18 18:45 38
    QString exposureTime;
53fdab93 Poul Sander 2026-05-18 18:45 39
    QString fNumber;
53fdab93 Poul Sander 2026-05-18 18:45 40
    QString iso;
53fdab93 Poul Sander 2026-05-18 18:45 41
    QString focalLength;
53fdab93 Poul Sander 2026-05-18 18:45 42
    QString flash;
700d6f2d Poul Sander 2026-06-06 15:44 43
    QString filename;
53fdab93 Poul Sander 2026-05-18 18:45 44
    QString dimensions;
53fdab93 Poul Sander 2026-05-18 18:45 45
    QString fileSize;
091a4f7d Poul Sander 2026-06-09 19:54 46
    QString orientation;
091a4f7d Poul Sander 2026-06-09 19:54 47
    QString latitude;
091a4f7d Poul Sander 2026-06-09 19:54 48
    QString longitude;
091a4f7d Poul Sander 2026-06-09 19:54 49
    QString osmLink;
53fdab93 Poul Sander 2026-05-18 18:45 50
53fdab93 Poul Sander 2026-05-18 18:45 51
    bool isEmpty() const;
53fdab93 Poul Sander 2026-05-18 18:45 52
    QList<QPair<QString, QString>> toList() const;
53fdab93 Poul Sander 2026-05-18 18:45 53
};
53fdab93 Poul Sander 2026-05-18 18:45 54
53fdab93 Poul Sander 2026-05-18 18:45 55
namespace ExifReader {
80a9926d Poul Sander 2026-05-19 20:28 56
ExifData read(const QByteArray &path);
beb4a823 Poul Sander 2026-05-19 21:53 57
beb4a823 Poul Sander 2026-05-19 21:53 58
// Write caption to IPTC Caption-Abstract.
beb4a823 Poul Sander 2026-05-19 21:53 59
// If oldData.captionAbstract == oldData.description they were in sync;
beb4a823 Poul Sander 2026-05-19 21:53 60
// in that case also update Exif.Image.ImageDescription to match.
beb4a823 Poul Sander 2026-05-19 21:53 61
// Returns true on success.
beb4a823 Poul Sander 2026-05-19 21:53 62
bool saveCaption(const QByteArray &path,
beb4a823 Poul Sander 2026-05-19 21:53 63
                 const QString    &caption,
beb4a823 Poul Sander 2026-05-19 21:53 64
                 const ExifData   &oldData);
48534775 Poul Sander 2026-06-08 18:57 65
48534775 Poul Sander 2026-06-08 18:57 66
// Rotate the image 90 degrees by updating the Exif.Image.Orientation tag only
48534775 Poul Sander 2026-06-08 18:57 67
// (lossless — pixel data is left untouched). clockwise=true rotates right.
48534775 Poul Sander 2026-06-08 18:57 68
// Returns true on success.
48534775 Poul Sander 2026-06-08 18:57 69
bool rotate(const QByteArray &path, bool clockwise);
53fdab93 Poul Sander 2026-05-18 18:45 70
} // namespace ExifReader
1970-01-01 00:00 71