From 204868d73369673a5c7e992aa27926e463d349b3 Mon Sep 17 00:00:00 2001 From: supertobi Date: Sun, 17 Apr 2016 12:33:39 +0200 Subject: [PATCH] Use a file list instead of * to zip the images kml_export - packs to kmz all files from dt.configuration.tmp_dir #53 https://github.com/darktable-org/lua-scripts/issues/53 --- contrib/kml_export.lua | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/contrib/kml_export.lua b/contrib/kml_export.lua index a3bdcd2..eeee8f5 100644 --- a/contrib/kml_export.lua +++ b/contrib/kml_export.lua @@ -142,7 +142,7 @@ function string.stripAccents( str ) tableAccents["Ý"] = "Y" local normalizedString = "" - dt.print_error(str) + for strChar in string.gmatch(str, "([%z\1-\127\194-\244][\128-\191]*)") do if tableAccents[strChar] ~= nil then normalizedString = normalizedString..tableAccents[strChar] @@ -177,6 +177,7 @@ local function create_kml_file(storage, image_table, extra_data) if not checkIfBinExists("zip") then return end + exportDirectory = dt.configuration.tmp_dir imageFoldername = "" else @@ -208,6 +209,7 @@ local function create_kml_file(storage, image_table, extra_data) -- USE coroutine.yield. It does not block the UI coroutine.yield("RUN_COMMAND", convertToThumbCommand) local concertCommand = "convert -size 438x438 "..exported_image.." -resize 438x438 +profile \"*\" "..exportDirectory.."/"..imageFoldername..filename..".jpg" + coroutine.yield("RUN_COMMAND", concertCommand) end @@ -320,9 +322,22 @@ local function create_kml_file(storage, image_table, extra_data) if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true ) then exportDirectory = dt.preferences.read("kml_export","ExportDirectory","string") -- USE coroutine.yield. It does not block the UI + local createKMZCommand = "zip --test --move --junk-paths " - createKMZCommand = createKMZCommand .."\""..exportDirectory.."/"..exportKMZFilename.."\" " - createKMZCommand = createKMZCommand .."\""..dt.configuration.tmp_dir.."/"..exportKMLFilename.."\" \""..dt.configuration.tmp_dir.."/"..imageFoldername.."\"*" + createKMZCommand = createKMZCommand .."\""..exportDirectory.."/"..exportKMZFilename.."\" " -- KMZ filename + createKMZCommand = createKMZCommand .."\""..dt.configuration.tmp_dir.."/"..exportKMLFilename.."\" " -- KML file + + for image,exported_image in pairs(image_table) do + if ((image.longitude and image.latitude) and + (image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data + ) then + local filename = string.upper(string.gsub(image.filename,"%.", "_")) + + createKMZCommand = createKMZCommand .."\""..dt.configuration.tmp_dir.."/"..imageFoldername.."thumb_"..filename..".jpg\" " -- thumbnails + createKMZCommand = createKMZCommand .."\""..dt.configuration.tmp_dir.."/"..imageFoldername..filename..".jpg\" " -- images + end + end + coroutine.yield("RUN_COMMAND", createKMZCommand) end