{"id":9556,"url":"https://patchwork.libcamera.org/api/patches/9556/?format=json","web_url":"https://patchwork.libcamera.org/patch/9556/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200909153206.7700-1-email@uajain.com>","date":"2020-09-09T15:32:06","name":"[libcamera-devel,RFC] android: jpeg: exif: Set timezone information","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"d51fb650c5da5ff74469f42078baada4309f3c3b","submitter":{"id":1,"url":"https://patchwork.libcamera.org/api/people/1/?format=json","name":"Umang Jain","email":"email@uajain.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/9556/mbox/","series":[{"id":1281,"url":"https://patchwork.libcamera.org/api/series/1281/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1281","date":"2020-09-09T15:32:06","name":"[libcamera-devel,RFC] android: jpeg: exif: Set timezone information","version":1,"mbox":"https://patchwork.libcamera.org/series/1281/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/9556/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/9556/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 36569BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  9 Sep 2020 15:32:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AFED662C30;\n\tWed,  9 Sep 2020 17:32:14 +0200 (CEST)","from mail.uajain.com (static.126.159.217.95.clients.your-server.de\n\t[95.217.159.126])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AC80560534\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  9 Sep 2020 17:32:12 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=uajain.com header.i=@uajain.com\n\theader.b=\"K+NQQRjF\"; dkim-atps=neutral","From":"Umang Jain <email@uajain.com>","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=uajain.com; s=mail;\n\tt=1599665531; bh=K8zEOPxYCxYGuLx+5Rn9EKmqM6HHzhGL9LVb30Edk5s=;\n\th=From:To:Cc:Subject;\n\tb=K+NQQRjFzeKD5JcJmqtCji1kQdD35JIv3sM0JAsXljB0IFymrs+R8ImyuKpThH39u\n\tz0M5zrVafVrazXnahCNnoZBSSEn7EGYSkxuy637d5pcURXk8jeLL/+F1tUwif0kUoU\n\tQeepaLliHn3FC4BoOOh/8jYefDWPUsRP0qvqtl6bexWh9uzGOEP5kYWQ7H3tnkbq93\n\tqNtRArT1POmDnigzCsPeKVs+GvgGAx4d8WWoPGj3CPynmYSD63okrKYbryik/sHhPt\n\tT+z5U/OZeug97LYscqHs97oSvSyLXGUT/wLzbjY4cbUljJ08HXWjRnWhenU0nsWnvM\n\tz2LhUTHOoj1ow==","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  9 Sep 2020 21:02:06 +0530","Message-Id":"<20200909153206.7700-1-email@uajain.com>","Mime-Version":"1.0","Subject":"[libcamera-devel] [RFC PATCH] android: jpeg: exif: Set timezone\n\tinformation","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Get timestamp information from the timestamp, although the resolution\nfor EXIF_TAG_TIME_ZONE_OFFSET is fairly limtied (per-hour only).\n\nExperimentation with 'exiftool', commandline utility to read/write\nexif metadata on images, resulted in rounding off the hours if the\nminutes came out to >= 30. Hence, the behaviour is inspired from\nexiftool itself. For e.g.,\n\nTimezone      Tag's value\n +1015     =>     10\n +0945     =>     10\n -1145     =>    -12\n\nSigned-off-by: Umang Jain <email@uajain.com>\n---\n src/android/jpeg/exif.cpp | 30 ++++++++++++++++++++++++++++++\n src/android/jpeg/exif.h   |  1 +\n 2 files changed, 31 insertions(+)","diff":"diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp\nindex 031f5f4..d8b4537 100644\n--- a/src/android/jpeg/exif.cpp\n+++ b/src/android/jpeg/exif.cpp\n@@ -135,6 +135,16 @@ void Exif::setShort(ExifIfd ifd, ExifTag tag, uint16_t item)\n \texif_entry_unref(entry);\n }\n \n+void Exif::setSShort(ExifIfd ifd, ExifTag tag, int16_t item)\n+{\n+\tExifEntry *entry = createEntry(ifd, tag);\n+\tif (!entry)\n+\t\treturn;\n+\n+\texif_set_sshort(entry->data, EXIF_BYTE_ORDER_INTEL, item);\n+\texif_entry_unref(entry);\n+}\n+\n void Exif::setLong(ExifIfd ifd, ExifTag tag, uint32_t item)\n {\n \tExifEntry *entry = createEntry(ifd, tag);\n@@ -194,6 +204,26 @@ void Exif::setTimestamp(time_t timestamp)\n \tsetString(EXIF_IFD_0, EXIF_TAG_DATE_TIME, EXIF_FORMAT_ASCII, ts);\n \tsetString(EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_ORIGINAL, EXIF_FORMAT_ASCII, ts);\n \tsetString(EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_DIGITIZED, EXIF_FORMAT_ASCII, ts);\n+\n+\t/* If possible, query and set timezone information via\n+\t * EXIF_TAG_TIME_ZONE_OFFSET. There is only per-hour resolution for tag\n+\t * hence, round up hours if minutes >= 30.\n+\t */\n+\tchar tz[6];\n+\tint r = std::strftime(tz, sizeof(tz), \"%z\", std::localtime(&timestamp));\n+\tif (r > 0) {\n+\t\tint16_t timezone = atoi(tz);\n+\t\tint16_t hour = timezone / 100;\n+\t\tint16_t min = abs(timezone) - (abs(hour) * 100);\n+\n+\t\tif (tz[0] == '-' && min >= 30)\n+\t\t\thour--;\n+\t\telse if (min >= 30)\n+\t\t\thour++;\n+\n+\t\t/* \\todo Check if EXIF IFD is correct here or not. */\n+\t\tsetSShort(EXIF_IFD_EXIF, EXIF_TAG_TIME_ZONE_OFFSET, hour);\n+\t}\n }\n \n void Exif::setOrientation(int orientation)\ndiff --git a/src/android/jpeg/exif.h b/src/android/jpeg/exif.h\nindex 622de4c..4817815 100644\n--- a/src/android/jpeg/exif.h\n+++ b/src/android/jpeg/exif.h\n@@ -37,6 +37,7 @@ private:\n \t\t\t       unsigned long components, unsigned int size);\n \n \tvoid setShort(ExifIfd ifd, ExifTag tag, uint16_t item);\n+\tvoid setSShort(ExifIfd ifd, ExifTag tag, int16_t item);\n \tvoid setLong(ExifIfd ifd, ExifTag tag, uint32_t item);\n \tvoid setString(ExifIfd ifd, ExifTag tag, ExifFormat format,\n \t\t       const std::string &item);\n","prefixes":["libcamera-devel","RFC"]}