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

Đang mở Phù hợp với người mới
#627 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
lua
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu trong lua/lib/dtutils/string.lua bằng cách đọc build_substitute_list và exiftime2systime, sau đó chạy script thay thế đã được báo cáo trên một hình ảnh không có dữ liệu thời gian EXIF. Hoàn thành khi dấu thời gian mặc định được chấp nhận mà không có lỗi os.time trên hệ thống bị ảnh hưởng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Lua
Star
219
Fork
142
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của darktable-org/lua-scripts

Tất cả issue của darktable-org/lua-scripts

Issue tương tự

Thêm issue về Lua

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.