Skip to content

Commit 539f255

Browse files
committed
contrib/fujifilm_ratings - added check to ensure the image is a
fujifilm file.
1 parent 9f2dbef commit 539f255

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

contrib/fujifilm_ratings.lua

+7-4
Original file line numberDiff line numberDiff line change
@@ -54,32 +54,35 @@ script_data.restart = nil -- how to restart the (lib) script after it's been hid
5454
script_data.show = nil -- only required for libs since the destroy_method only hides them
5555

5656
local function detect_rating(event, image)
57+
if not string.match(image.filename, "%.RAF$") and not string.match(image.filename, "%.raf$") then
58+
return
59+
end
5760
if not df.check_if_bin_exists("exiftool") then
5861
dt.print_error(_("exiftool not found"))
5962
return
6063
end
6164
local RAF_filename = df.sanitize_filename(tostring(image))
6265
local JPEG_filename = string.gsub(RAF_filename, "%.RAF$", ".JPG")
6366
local command = "exiftool -Rating " .. JPEG_filename
64-
dt.print_error(command)
67+
dt.print_log(command)
6568
local output = dtsys.io_popen(command)
6669
local jpeg_result = output:read("*all")
6770
output:close()
6871
if string.len(jpeg_result) > 0 then
6972
jpeg_result = string.gsub(jpeg_result, "^Rating.*(%d)", "%1")
7073
image.rating = tonumber(jpeg_result)
71-
dt.print_error(string.format(_("using JPEG rating: %d"), jpeg_result))
74+
dt.print_log("using JPEG rating: " .. jpeg_result)
7275
return
7376
end
7477
command = "exiftool -Rating " .. RAF_filename
75-
dt.print_error(command)
78+
dt.print_log(command)
7679
output = dtsys.io_popen(command)
7780
local raf_result = output:read("*all")
7881
output:close()
7982
if string.len(raf_result) > 0 then
8083
raf_result = string.gsub(raf_result, "^Rating.*(%d)", "%1")
8184
image.rating = tonumber(raf_result)
82-
dt.print_error(string.format(_("using RAF rating: %d"), raf_result))
85+
dt.print_log("using RAF rating: " .. raf_result)
8386
end
8487
end
8588

0 commit comments

Comments
 (0)