Merge pull request #473 from wpferguson/fix_472_fujifilm_ratings
Fix fujifilm ratings
This commit is contained in:
@@ -54,6 +54,9 @@ script_data.restart = nil -- how to restart the (lib) script after it's been hid
|
|||||||
script_data.show = nil -- only required for libs since the destroy_method only hides them
|
script_data.show = nil -- only required for libs since the destroy_method only hides them
|
||||||
|
|
||||||
local function detect_rating(event, image)
|
local function detect_rating(event, image)
|
||||||
|
if not string.match(image.filename, "%.RAF$") and not string.match(image.filename, "%.raf$") then
|
||||||
|
return
|
||||||
|
end
|
||||||
if not df.check_if_bin_exists("exiftool") then
|
if not df.check_if_bin_exists("exiftool") then
|
||||||
dt.print_error(_("exiftool not found"))
|
dt.print_error(_("exiftool not found"))
|
||||||
return
|
return
|
||||||
@@ -61,25 +64,25 @@ local function detect_rating(event, image)
|
|||||||
local RAF_filename = df.sanitize_filename(tostring(image))
|
local RAF_filename = df.sanitize_filename(tostring(image))
|
||||||
local JPEG_filename = string.gsub(RAF_filename, "%.RAF$", ".JPG")
|
local JPEG_filename = string.gsub(RAF_filename, "%.RAF$", ".JPG")
|
||||||
local command = "exiftool -Rating " .. JPEG_filename
|
local command = "exiftool -Rating " .. JPEG_filename
|
||||||
dt.print_error(command)
|
dt.print_log(command)
|
||||||
local output = dtsys.io_popen(command)
|
local output = dtsys.io_popen(command)
|
||||||
local jpeg_result = output:read("*all")
|
local jpeg_result = output:read("*all")
|
||||||
output:close()
|
output:close()
|
||||||
if string.len(jpeg_result) > 0 then
|
if string.len(jpeg_result) > 0 then
|
||||||
jpeg_result = string.gsub(jpeg_result, "^Rating.*(%d)", "%1")
|
jpeg_result = string.gsub(jpeg_result, "^Rating.*(%d)", "%1")
|
||||||
image.rating = tonumber(jpeg_result)
|
image.rating = tonumber(jpeg_result)
|
||||||
dt.print_error(string.format(_("using JPEG rating: %d"), jpeg_result))
|
dt.print_log("using JPEG rating: " .. jpeg_result)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
command = "exiftool -Rating " .. RAF_filename
|
command = "exiftool -Rating " .. RAF_filename
|
||||||
dt.print_error(command)
|
dt.print_log(command)
|
||||||
output = dtsys.io_popen(command)
|
output = dtsys.io_popen(command)
|
||||||
local raf_result = output:read("*all")
|
local raf_result = output:read("*all")
|
||||||
output:close()
|
output:close()
|
||||||
if string.len(raf_result) > 0 then
|
if string.len(raf_result) > 0 then
|
||||||
raf_result = string.gsub(raf_result, "^Rating.*(%d)", "%1")
|
raf_result = string.gsub(raf_result, "^Rating.*(%d)", "%1")
|
||||||
image.rating = tonumber(raf_result)
|
image.rating = tonumber(raf_result)
|
||||||
dt.print_error(string.format(_("using RAF rating: %d"), raf_result))
|
dt.print_log("using RAF rating: " .. raf_result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user