[{"id":5213,"web_url":"https://patchwork.libcamera.org/comment/5213/","msgid":"<20200616023036.GC29596@pendragon.ideasonboard.com>","date":"2020-06-16T02:30:36","subject":"Re: [libcamera-devel] [PATCH v3] qcam: dng_writer: Record creation\n\ttime in the EXIF directory","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Mon, Jun 15, 2020 at 05:51:43PM +0200, Niklas Söderlund wrote:\n> If the EXIF directory is empty due to no metadata being available tools\n> such as tiffinfo complains that the directory is malformed.\n> \n>     TIFFFetchDirectory: Sanity check on directory count failed, this is probably not a valid IFD offset.\n>     TIFFReadCustomDirectory: Failed to read custom directory at offset 0.\n> \n> Always record the creation time in the EXIF directory instead of adding\n> complexity to skip creating the EXIF directory if there is no metadata\n> to record. This ensures there are at least some entries in the EXIF\n> directory and that makes tiffinfo happy.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n> * Changes since v1\n> - Also set EXIFTAG_DATETIMEORIGINAL\n> * Changes since v2\n> - Add todo to not forget to add OffsetTimeOriginal and\n>   OffsetTimeDigitized once libtff learns about them.\n> ---\n>  src/qcam/dng_writer.cpp | 17 +++++++++++++++++\n>  1 file changed, 17 insertions(+)\n> \n> diff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp\n> index 8470908816e3e408..d5667c863cada250 100644\n> --- a/src/qcam/dng_writer.cpp\n> +++ b/src/qcam/dng_writer.cpp\n> @@ -427,6 +427,23 @@ int DNGWriter::write(const char *filename, const Camera *camera,\n>  \t/* Create a new IFD for the EXIF data and fill it. */\n>  \tTIFFCreateEXIFDirectory(tif);\n>  \n> +\t/* Store creation time. */\n> +\ttime_t rawtime;\n> +\tstruct tm *timeinfo;\n> +\tchar strTime[20];\n> +\n> +\ttime(&rawtime);\n> +\ttimeinfo = localtime(&rawtime);\n> +\tstrftime(strTime, 20, \"%Y:%m:%d %H:%M:%S\", timeinfo);\n> +\n> +\t/*\n> +\t * \\todo Handle timezone information by setting OffsetTimeOriginal and\n> +\t * OffsetTimeDigitized once libtiff catches up to the specification and\n> +\t * have EXIFTAG_ defines to handle them.\n\ns/have/has/\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t */\n> +\tTIFFSetField(tif, EXIFTAG_DATETIMEORIGINAL, strTime);\n> +\tTIFFSetField(tif, EXIFTAG_DATETIMEDIGITIZED, strTime);\n> +\n>  \tif (metadata.contains(controls::AnalogueGain)) {\n>  \t\tfloat gain = metadata.get(controls::AnalogueGain);\n>  \t\tuint16_t iso = std::min(std::max(gain * 100, 0.0f), 65535.0f);","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DA63C61167\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Jun 2020 04:30:58 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 73BC4F9;\n\tTue, 16 Jun 2020 04:30:58 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Hd2ZpBST\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1592274658;\n\tbh=A91ESL1Yos1EUN0T2nIC872N9NSD7R6OMuRvhfP9rzY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Hd2ZpBSTwUsPuvIRR9Ya8mEhfwTt6wkF8H2aia3w2JbFCn4a8rwntgMnaAfaLL/dJ\n\tG+W5YpW9r37CxaGSNisWzx1P5HhUqbCUxiYmG172wNbAwS4sXkwHuEvCe2OY3Jb0rw\n\twJ3JJLDmu/R70jWZ5dsou5MWSIQVrB/xb3zz17sg=","Date":"Tue, 16 Jun 2020 05:30:36 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200616023036.GC29596@pendragon.ideasonboard.com>","References":"<20200615155143.2609284-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200615155143.2609284-1-niklas.soderlund@ragnatech.se>","Subject":"Re: [libcamera-devel] [PATCH v3] qcam: dng_writer: Record creation\n\ttime in the EXIF directory","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>","X-List-Received-Date":"Tue, 16 Jun 2020 02:30:59 -0000"}}]