Skip to content

Commit eeaa6b4

Browse files
authored
Merge pull request darktable-org#171 from darktable-org/supertobi-patch-1
make kml_export multi OS
2 parents a383d1e + 53d6b54 commit eeaa6b4

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

contrib/kml_export.lua

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ 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
81+
7682
if not df.check_if_bin_exists(magickPath) then
7783
dt.print_error(_("magick not found"))
7884
return
@@ -116,10 +122,13 @@ local function create_kml_file(storage, image_table, extra_data)
116122
-- will be scaled so its largest dimension is 120 pixels. The '+profile "*"' removes any ICM, EXIF, IPTC, or other
117123
-- profiles that might be present in the input and aren't needed in the thumbnail.
118124

119-
local convertToThumbCommand = ds.sanitize(magickPath) .. " -size 96x96 "..exported_image.." -resize 92x92 -mattecolor \"#FFFFFF\" -frame 2x2 +profile \"*\" "..exportDirectory..PS..imageFoldername.."thumb_"..filename..".jpg"
125+
local convertToThumbCommand = ds.sanitize(magickPath) .. " -size 96x96 " .. exported_image .. " -resize 92x92 -mattecolor \"#FFFFFF\" -frame 2x2 +profile \"*\" " .. exportDirectory .. PS .. imageFoldername .. "thumb_" .. filename .. ".jpg"
126+
127+
if (exported_image ~= exportDirectory..PS..imageFoldername..filename.."."..filetype) then
128+
df.file_copy(exported_image, exportDirectory..PS..imageFoldername..filename.."."..filetype)
129+
end
130+
dsys.external_command(convertToThumbCommand)
120131

121-
df.file_copy(exported_image, exportDirectory..PS..imageFoldername..filename.."."..filetype)
122-
dsys.external_command(convertToThumbCommand)
123132
else
124133
-- Remove exported image if it has no GPS data
125134
os.remove(exported_image)
@@ -132,17 +141,17 @@ local function create_kml_file(storage, image_table, extra_data)
132141
-- https://github.com/darktable-org/lua-scripts/issues/54
133142
filmName = ds.strip_accents(filmName)
134143

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
144+
-- Remove chars we don't like to have in filenames
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, "*", "")
153+
filmName = string.gsub(filmName, "?", "")
154+
filmName = string.gsub(filmName,'[.]', "") -- At least Windwows has problems with the "." and the start command
146155
end
147156

148157
exportKMLFilename = filmName..".kml"

0 commit comments

Comments
 (0)