Skip to content

Commit ffd6abb

Browse files
authored
Fixed bugs after Linux testing
1 parent f08421a commit ffd6abb

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

contrib/kml_export.lua

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ end
7272

7373
local function create_kml_file(storage, image_table, extra_data)
7474

75-
local magickPath = dt.preferences.read("kml_export","magickPath","string")
75+
local magickPath
76+
if dt.configuration.running_os == "linux" then
77+
magickPath = 'convert'
78+
else
79+
magickPath = dt.preferences.read("kml_export","magickPath","string")
80+
end
7681
if not df.check_if_bin_exists(magickPath) then
7782
dt.print_error(_("magick not found"))
7883
return
@@ -116,10 +121,12 @@ local function create_kml_file(storage, image_table, extra_data)
116121
-- will be scaled so its largest dimension is 120 pixels. The '+profile "*"' removes any ICM, EXIF, IPTC, or other
117122
-- profiles that might be present in the input and aren't needed in the thumbnail.
118123

119-
local convertToThumbCommand = ds.sanitize(magickPath) .. " -size 96x96 "..exported_image.." -resize 92x92 -mattecolor \"#FFFFFF\" -frame 2x2 +profile \"*\" "..exportDirectory..PS..imageFoldername.."thumb_"..filename..".jpg"
124+
local convertToThumbCommand = ds.sanitize(magickPath) .. " -size 96x96 " .. exported_image .. " -resize 92x92 -mattecolor \"#FFFFFF\" -frame 2x2 +profile \"*\" " .. exportDirectory .. PS .. imageFoldername .. "thumb_" .. filename .. ".jpg"
120125

121-
df.file_copy(exported_image, exportDirectory..PS..imageFoldername..filename.."."..filetype)
122-
dsys.external_command(convertToThumbCommand)
126+
if (exported_image ~= exportDirectory..PS..imageFoldername..filename.."."..filetype) then
127+
df.file_copy(exported_image, exportDirectory..PS..imageFoldername..filename.."."..filetype)
128+
end
129+
dsys.external_command(convertToThumbCommand)
123130
else
124131
-- Remove exported image if it has no GPS data
125132
os.remove(exported_image)
@@ -132,17 +139,17 @@ local function create_kml_file(storage, image_table, extra_data)
132139
-- https://github.com/darktable-org/lua-scripts/issues/54
133140
filmName = ds.strip_accents(filmName)
134141

135-
-- Remove chars we don't like to have in filenames
136-
filmName = string.gsub(filmName, [[\]], "")
137-
filmName = string.gsub(filmName, [[/]], "")
138-
filmName = string.gsub(filmName, [[:]], "")
139-
filmName = string.gsub(filmName, [["]], "")
140-
filmName = string.gsub(filmName, "<", "")
141-
filmName = string.gsub(filmName, ">", "")
142-
filmName = string.gsub(filmName, "|", "")
143-
filmName = string.gsub(filmName, "*", "")
144-
filmName = string.gsub(filmName, "?", "")
145-
filmName = string.gsub(filmName,'[.]', "") -- At least Windwows has problems with the "." and the start command
142+
-- Remove chars we don't like to have in filenames
143+
filmName = string.gsub(filmName, [[\]], "")
144+
filmName = string.gsub(filmName, [[/]], "")
145+
filmName = string.gsub(filmName, [[:]], "")
146+
filmName = string.gsub(filmName, [["]], "")
147+
filmName = string.gsub(filmName, "<", "")
148+
filmName = string.gsub(filmName, ">", "")
149+
filmName = string.gsub(filmName, "|", "")
150+
filmName = string.gsub(filmName, "*", "")
151+
filmName = string.gsub(filmName, "?", "")
152+
filmName = string.gsub(filmName,'[.]', "") -- At least Windwows has problems with the "." and the start command
146153
end
147154

148155
exportKMLFilename = filmName..".kml"

0 commit comments

Comments
 (0)