darktable-org / darktable-org/lua-scripts

function "dtutils.string.substitute()" fails when no time data is provided in Exif data

オープン 初心者向け
#627 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Lua
スター
219
フォーク
142
PR マージ指標
30日以内にマージされた PR はありません

説明

When running a script using "dtutils.string.substitute()" function on a file without any time data in Exif, the "dtutils.string.substitute()" function fails.

190.9832 LUA ERROR : ...\AppData\Local\darktable/lua/lib/dtutils\string.lua:748: time result cannot be represented in this installation
stack traceback:
	[C]: in ?
	[C]: in function 'os.time'
	...AppData\Local\darktable/lua/lib/dtutils\string.lua:748: in upvalue 'exiftime2systime'
	...AppData\Local\darktable/lua/lib/dtutils\string.lua:843: in function 'lib/dtutils.string.build_substitute_list'
	...AppData\Local\darktable/lua/lib/dtutils\string.lua:1298: in function 'lib/dtutils.string.substitute'

After looking at the "string.lua" code, it seems that "build_substitute_list" function tries to use "0000:00:00 00:00:00" as default value if the exif time is not available, but the "os.time{}" conversion called later through "exiftime2systime(datetime_taken)" does not like it. The minimum time value accepted on several systems is January 1st, 1970. I updated the "string.lua" code on my installation (replacing "0000:00:00 00:00:00" with "1970:01:01 00:00:00") and this fixes the issue.

Code from string.lua :

local function exiftime2systime(exiftime)
  local yr,mo,dy,h,m,s = string.match(exiftime, "(%d-):(%d-):(%d-) (%d-):(%d-):(%d+)")
  return(os.time{year=yr, month=mo, day=dy, hour=h, min=m, sec=s})
end

[...]

function dtutils_string.build_substitute_list(image, sequence, variable_string, username, pic_folder, home, desktop)
[...]
  if image.exif_datetime_taken and image.exif_datetime_taken ~= "" then
    datetime_taken = image.exif_datetime_taken
  else
    if use_millisecs then
      datetime_taken = "0000:00:00 00:00:00.0"
    else
      datetime_taken = "0000:00:00 00:00:00"
    end
  end
[...]

I see this issue on Windows 11, DarkTable 5.4.0. Other systems could behave the same, or not.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

lua/lib/dtutils/string.lua で build_substitute_list と exiftime2systime を読み始め、その後、EXIF 時刻データのない画像に対して報告された置換スクリプトを実行します。影響を受けるシステムで、デフォルトのタイムスタンプが os.time エラーなしに受け入れられれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
lua
領域
tooling
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
78/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。