qcam: dng_writer: Record creation time in the EXIF directory
If the EXIF directory is empty due to no metadata being available tools such as tiffinfo complains that the directory is malformed. TIFFFetchDirectory: Sanity check on directory count failed, this is probably not a valid IFD offset. TIFFReadCustomDirectory: Failed to read custom directory at offset 0. Always record the creation time in the EXIF directory instead of adding complexity to skip creating the EXIF directory if there is no metadata to record. This ensures there are at least some entries in the EXIF directory and that makes tiffinfo happy. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
9d4fb49dbc
commit
bf650cf3fc
1 changed files with 17 additions and 0 deletions
|
@ -427,6 +427,23 @@ int DNGWriter::write(const char *filename, const Camera *camera,
|
||||||
/* Create a new IFD for the EXIF data and fill it. */
|
/* Create a new IFD for the EXIF data and fill it. */
|
||||||
TIFFCreateEXIFDirectory(tif);
|
TIFFCreateEXIFDirectory(tif);
|
||||||
|
|
||||||
|
/* Store creation time. */
|
||||||
|
time_t rawtime;
|
||||||
|
struct tm *timeinfo;
|
||||||
|
char strTime[20];
|
||||||
|
|
||||||
|
time(&rawtime);
|
||||||
|
timeinfo = localtime(&rawtime);
|
||||||
|
strftime(strTime, 20, "%Y:%m:%d %H:%M:%S", timeinfo);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* \todo Handle timezone information by setting OffsetTimeOriginal and
|
||||||
|
* OffsetTimeDigitized once libtiff catches up to the specification and
|
||||||
|
* has EXIFTAG_ defines to handle them.
|
||||||
|
*/
|
||||||
|
TIFFSetField(tif, EXIFTAG_DATETIMEORIGINAL, strTime);
|
||||||
|
TIFFSetField(tif, EXIFTAG_DATETIMEDIGITIZED, strTime);
|
||||||
|
|
||||||
if (metadata.contains(controls::AnalogueGain)) {
|
if (metadata.contains(controls::AnalogueGain)) {
|
||||||
float gain = metadata.get(controls::AnalogueGain);
|
float gain = metadata.get(controls::AnalogueGain);
|
||||||
uint16_t iso = std::min(std::max(gain * 100, 0.0f), 65535.0f);
|
uint16_t iso = std::min(std::max(gain * 100, 0.0f), 65535.0f);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue