summaryrefslogtreecommitdiff
path: root/src/android/jpeg
diff options
context:
space:
mode:
authorUmang Jain <email@uajain.com>2020-09-25 00:06:42 +0530
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-09-29 05:55:08 +0300
commitde20d00455fbd87815a0946eaf957a9368e72a6a (patch)
tree581491511a121ab8d25937f98417c263d74ee321 /src/android/jpeg
parent51bfc823921095b301a6c68e9e59d8cb4e2ffc2d (diff)
android: jpeg: exif: Set timezone information
The EXIF specification defines three timezone related tags, namely OffsetTime, OffsetTimeOriginal and OffsetTimeDigitized. However, these are not supported by libexif (as of v0.6.21) hence, carry the tags' positional values in our implementation until we get this support from libexif itself. Since these tags were introduced in EXIF specification v2.31, set the exif version number explicitly too. Signed-off-by: Umang Jain <email@uajain.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/android/jpeg')
-rw-r--r--src/android/jpeg/exif.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp
index a5674b3d..32cf8974 100644
--- a/src/android/jpeg/exif.cpp
+++ b/src/android/jpeg/exif.cpp
@@ -14,6 +14,16 @@ using namespace libcamera;
LOG_DEFINE_CATEGORY(EXIF)
/*
+ * List of EXIF tags that we set directly because they are not supported
+ * by libexif version 0.6.21.
+ */
+enum class _ExifTag {
+ OFFSET_TIME = 0x9010,
+ OFFSET_TIME_ORIGINAL = 0x9011,
+ OFFSET_TIME_DIGITIZED = 0x9012,
+};
+
+/*
* The Exif class should be instantiated and specific properties set
* through the exposed public API.
*
@@ -51,6 +61,9 @@ Exif::Exif()
*/
exif_data_set_byte_order(data_, EXIF_BYTE_ORDER_INTEL);
+ setString(EXIF_IFD_EXIF, EXIF_TAG_EXIF_VERSION,
+ EXIF_FORMAT_UNDEFINED, "0231");
+
/* Create the mandatory EXIF fields with default data. */
exif_data_fix(data_);
}
@@ -197,6 +210,22 @@ void Exif::setTimestamp(time_t timestamp)
setString(EXIF_IFD_0, EXIF_TAG_DATE_TIME, EXIF_FORMAT_ASCII, ts);
setString(EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_ORIGINAL, EXIF_FORMAT_ASCII, ts);
setString(EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_DIGITIZED, EXIF_FORMAT_ASCII, ts);
+
+ /* Query and set timezone information if available. */
+ int r = strftime(str, sizeof(str), "%z", &tm);
+ if (r > 0) {
+ std::string tz(str);
+ tz.insert(3, 1, ':');
+ setString(EXIF_IFD_EXIF,
+ static_cast<ExifTag>(_ExifTag::OFFSET_TIME),
+ EXIF_FORMAT_ASCII, tz);
+ setString(EXIF_IFD_EXIF,
+ static_cast<ExifTag>(_ExifTag::OFFSET_TIME_ORIGINAL),
+ EXIF_FORMAT_ASCII, tz);
+ setString(EXIF_IFD_EXIF,
+ static_cast<ExifTag>(_ExifTag::OFFSET_TIME_DIGITIZED),
+ EXIF_FORMAT_ASCII, tz);
+ }
}
void Exif::setOrientation(int orientation)