Skip to content

Commit

Permalink
Added HEIC support
Browse files Browse the repository at this point in the history
  • Loading branch information
fuxs committed May 17, 2021
1 parent 698f6a4 commit 9ad4aea
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 18 deletions.
44 changes: 34 additions & 10 deletions src/Configuration.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Configuration.lua
------------------------------------------------------------------------------]]

local LrPrefs = import "LrPrefs"
local LrDialogs = import "LrDialogs"

Configuration = {}

Expand Down Expand Up @@ -62,6 +63,7 @@ function Configuration.new()
useFileType = false,
preferRaw = true,
preferDng = true,
preferHeic= true,
preferLarge = true,
preferDimension = true,
preferRating = true,
Expand All @@ -71,21 +73,41 @@ function Configuration.new()
preferLongPath = false,
preferRawPos = "1",
preferDngPos = "2",
preferLargePos = "3",
preferDimensionPos = "4",
preferRatingPos = "5",
preferShortNamePos = "6",
preferLongNamePos = "7",
preferShortPathPos = "8",
preferLongPathPos = "9",
preferHeicPos = "3",
preferLargePos = "4",
preferDimensionPos = "5",
preferRatingPos = "6",
preferShortNamePos = "7",
preferLongNamePos = "8",
preferShortPathPos = "9",
preferLongPathPos = "10",
ignoreEmptyCaptureDate = true,
useScanDate = true,
useLabels = true
useLabels = true,
versionNumber = 42,
}
local prefs = LrPrefs.prefsForPlugin()
local aux = prefs.settings
if aux == nil then aux = defaultSettings end

local saveIt = false
local version
if aux.versionNumber == nil then
verb = LrDialogs.confirm("New Configuration Options","Reset order marks? All other options won't be touched. Please","Yes", "No")
if verb == "ok" then
aux.preferRawPos = "1"
aux.preferDngPos = "2"
aux.preferHeicPos = "3"
aux.preferLargePos = "4"
aux.preferDimensionPos = "5"
aux.preferRatingPos = "6"
aux.preferShortNamePos = "7"
aux.preferLongNamePos = "8"
aux.preferShortPathPos = "9"
aux.preferLongPathPos = "10"
saveIt = true
end
end
self.settings = {}
-- clone table
for k,v in pairs(defaultSettings) do
Expand All @@ -95,7 +117,9 @@ function Configuration.new()
end
self.settings[k] = temp
end

if saveIt then
prefs.settings = self.settings
end

function self.copyTo(t)
for k,v in pairs(self.settings) do t[k] = v end
Expand All @@ -112,6 +136,6 @@ function Configuration.new()
function self.copyDefaultsTo(t)
for k,v in pairs(defaultSettings) do t[k] = v end
end

return self
end
44 changes: 36 additions & 8 deletions src/Teekesselchen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ end

local function preferRAW(tree,photo,flag,label)
local header = tree[2]
local headRAW = header:getRawMetadata("fileFormat") == "RAW"
local photoRAW = photo:getRawMetadata("fileFormat") == "RAW"
if headRaw then
local headMatch = header:getRawMetadata("fileFormat") == "RAW"
local photoMatch = photo:getRawMetadata("fileFormat") == "RAW"
if headMatch then
insertFlaggedPhoto(tree,photo,flag,label)
return true
else
if photoRAW then
if photoMatch then
changeOrder(tree,photo,flag,label)
return true
end
Expand All @@ -101,13 +101,29 @@ end

local function preferDNG(tree,photo,flag,label)
local header = tree[2]
local headRAW = header:getRawMetadata("fileFormat") == "DNG" --@mno since I do not use RAW but DNG this works for me.
local photoRAW = photo:getRawMetadata("fileFormat") == "DNG" --@mno more elegant would be to check for both values.
if headRaw then
local headMatch = header:getRawMetadata("fileFormat") == "DNG" --@mno since I do not use RAW but DNG this works for me.
local photoMatch = photo:getRawMetadata("fileFormat") == "DNG" --@mno more elegant would be to check for both values.
if headMatch then
insertFlaggedPhoto(tree,photo,flag,label)
return true
else
if photoRAW then
if photoMatch then
changeOrder(tree,photo,flag,label)
return true
end
end
return false
end

local function preferHEIC(tree,photo,flag,label)
local header = tree[2]
local headMatch = header:getRawMetadata("fileFormat") == "HEIC"
local photoMatch = photo:getRawMetadata("fileFormat") == "HEIC"
if headMatch then
insertFlaggedPhoto(tree,photo,flag,label)
return true
else
if photoMatch then
changeOrder(tree,photo,flag,label)
return true
end
Expand Down Expand Up @@ -572,9 +588,21 @@ function Teekesselchen.new(context)
if settings.preferDng then
pos = tonumber(settings.preferDngPos)
if pos >= 0 then
while sortingTable[pos] do
pos = pos + 1
end
sortingTable[pos] = preferDNG
end
end
if settings.preferHeic then
pos = tonumber(settings.preferHeicPos)
if pos >= 0 then
while sortingTable[pos] do
pos = pos + 1
end
sortingTable[pos] = preferHEIC
end
end
if settings.preferLarge then
pos = tonumber(settings.preferLargePos)
if pos >= 0 then
Expand Down
13 changes: 13 additions & 0 deletions src/TeekesselchenDialog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,19 @@ local function showFindDuplicatesDialog()
validate = teekesselchen.check_numberValue,
},
},
f:row {
f:checkbox {
title = "Prefer HEIC files",
value = LrView.bind("preferHeic"),
-- enabled = LrView.bind "useFlag",
width = LrView.share("prefer_width"),
},
f:edit_field {
value = LrView.bind("preferHeicPos"),
width_in_chars = 2,
validate = teekesselchen.check_numberValue,
},
},
f:row {
f:checkbox {
title = "Prefer larger files",
Expand Down

0 comments on commit 9ad4aea

Please sign in to comment.