JXR: added support to EXIF metadata

Improved metadata support via EXIF ​​metadata. Since JXR is based on a TIFF container, EXIF ​​data is read directly from the file so it always works (even with versions of libjxr that don't have the metadata reading API).

It also solves the following issues:
- Incorrect date format on saved JXR files (was saved in ISO format instead of `yyyy:MM:dd HH:mm:ss`).
- Incorrect date type setting in EXIF ​​data: the `DateTime` tag should be updated on every save (verified by GIMP and Photoshop). Our `CreationDate` metadata is the equivalent of the EXIF ​​`DateTimeOriginal` tag.

Closes #22
This commit is contained in:
Mirco Miranda
2025-02-23 00:38:27 +00:00
committed by Albert Astals Cid
parent 90d4256f3d
commit e5cf9caac5
17 changed files with 327 additions and 42 deletions

View File

@ -201,6 +201,20 @@ public:
QDateTime dateTime() const;
void setDateTime(const QDateTime& dt);
/*!
* \brief dateTimeOriginal
* \return The date and time when the original image data was generated.
*/
QDateTime dateTimeOriginal() const;
void setDateTimeOriginal(const QDateTime& dt);
/*!
* \brief dateTimeDigitized
* \return The date and time when the image was stored as digital data.
*/
QDateTime dateTimeDigitized() const;
void setDateTimeDigitized(const QDateTime& dt);
/*!
* \brief title
* \return The title of the image.
@ -239,17 +253,58 @@ public:
/*!
* \brief toByteArray
* Converts the class to RAW data. The raw data contains:
* - TIFF header
* - MAIN IFD
* - EXIF IFD
* - GPS IFD
* \param byteOrder Sets the serialization byte order for EXIF data.
* \return A byte array containing the serialized data.
* \sa write
*/
QByteArray toByteArray(const QDataStream::ByteOrder &byteOrder = EXIF_DEFAULT_BYTEORDER) const;
/*!
* \brief exifIfdByteArray
* Convert the EXIF IFD only to RAW data. Useful when you want to add EXIF data to an existing TIFF container.
* \param byteOrder Sets the serialization byte order for the data.
* \return A byte array containing the serialized data.
*/
QByteArray exifIfdByteArray(const QDataStream::ByteOrder &byteOrder = EXIF_DEFAULT_BYTEORDER) const;
/*!
* \brief setExifIfdByteArray
* \param ba The RAW data of EXIF IFD.
* \param byteOrder Sets the serialization byte order of the data.
* \return True on success, otherwise false.
*/
bool setExifIfdByteArray(const QByteArray& ba, const QDataStream::ByteOrder &byteOrder = EXIF_DEFAULT_BYTEORDER);
/*!
* \brief gpsIfdByteArray
* Convert the GPS IFD only to RAW data. Useful when you want to add GPS data to an existing TIFF container.
* \param byteOrder Sets the serialization byte order for the data.
* \return A byte array containing the serialized data.
*/
QByteArray gpsIfdByteArray(const QDataStream::ByteOrder &byteOrder = EXIF_DEFAULT_BYTEORDER) const;
/*!
* \brief setGpsIfdByteArray
* \param ba The RAW data of GPS IFD.
* \param byteOrder Sets the serialization byte order of the data.
* \return True on success, otherwise false.
*/
bool setGpsIfdByteArray(const QByteArray& ba, const QDataStream::ByteOrder &byteOrder = EXIF_DEFAULT_BYTEORDER);
/*!
* \brief write
* Serialize the class on a device.
* Serialize the class on a device. The serialized data contains:
* - TIFF header
* - MAIN IFD
* - EXIF IFD
* - GPS IFD
* \param device A random access device.
* \param byteOrder Sets the serialization byte order for EXIF data.
* \return True on success, otherwise false.
* \sa toByteArray
*/
bool write(QIODevice *device, const QDataStream::ByteOrder &byteOrder = EXIF_DEFAULT_BYTEORDER) const;