@@ -23,34 +23,48 @@ Dependencies:
23
23
24
24
--]]
25
25
26
- darktable = require " darktable"
26
+ local dt = require " darktable"
27
+ local df = require " lib/dtutils.file"
28
+ local gettext = dt .gettext
29
+
30
+ dt .configuration .check_version (... , {4 ,0 ,0 })
31
+
32
+ gettext .bindtextdomain (" fujifilm_ratings" , dt .configuration .config_dir .. " /lua/locale/" )
33
+
34
+ local function _ (msgid )
35
+ return gettext .dgettext (" fujifilm_ratings" , msgid )
36
+ end
27
37
28
38
local function detect_rating (event , image )
39
+ if not df .check_if_bin_exists (" exiftool" ) then
40
+ dt .print_error (_ (" exiftool not found" ))
41
+ return
42
+ end
29
43
local RAF_filename = tostring (image )
30
44
local JPEG_filename = string.gsub (RAF_filename , " %.RAF$" , " .JPG" )
31
45
local command = " exiftool -Rating " .. JPEG_filename
32
- darktable .print_error (command )
46
+ dt .print_error (command )
33
47
local output = io.popen (command )
34
48
local jpeg_result = output :read (" *all" )
35
49
output :close ()
36
50
if string.len (jpeg_result ) > 0 then
37
51
jpeg_result = string.gsub (jpeg_result , " ^Rating.*(%d)" , " %1" )
38
52
image .rating = tonumber (jpeg_result )
39
- darktable .print_error (" Using JPEG Rating: " .. tostring (jpeg_result ))
53
+ dt .print_error (_ ( " Using JPEG Rating: " ) .. tostring (jpeg_result ))
40
54
return
41
55
end
42
56
command = " exiftool -Rating " .. RAF_filename
43
- darktable .print_error (command )
57
+ dt .print_error (command )
44
58
output = io.popen (command )
45
59
local raf_result = output :read (" *all" )
46
60
output :close ()
47
61
if string.len (raf_result ) > 0 then
48
62
raf_result = string.gsub (raf_result , " ^Rating.*(%d)" , " %1" )
49
63
image .rating = tonumber (raf_result )
50
- darktable .print_error (" Using RAF Rating: " .. tostring (raf_result ))
64
+ dt .print_error (_ ( " Using RAF Rating: " ) .. tostring (raf_result ))
51
65
end
52
66
end
53
67
54
- darktable .register_event (" post-import-image" , detect_rating )
68
+ dt .register_event (" post-import-image" , detect_rating )
55
69
56
- darktable . print_error ( " fujifilm_ratings loaded." )
70
+ print ( _ ( " fujifilm_ratings loaded." ) )
0 commit comments