Skip to content

Commit 31cdd3f

Browse files
authored
Merge pull request #526 from wpferguson/substitution_library_updates
Substitution library updates
2 parents 631d89e + a835ab8 commit 31cdd3f

File tree

1 file changed

+122
-87
lines changed

1 file changed

+122
-87
lines changed

lib/dtutils/string.lua

Lines changed: 122 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ local PLACEHOLDERS = {"ROLL.NAME",
557557
"MONTH.SHORT",
558558
"DAY",
559559
"HOUR",
560+
"HOUR.AMPM", -- Not Implemented
560561
"MINUTE",
561562
"SECOND",
562563
"MSEC",
@@ -567,6 +568,7 @@ local PLACEHOLDERS = {"ROLL.NAME",
567568
"EXIF.MONTH.SHORT",
568569
"EXIF.DAY",
569570
"EXIF.HOUR",
571+
"EXIF.HOUR.AMPM", -- Not Implemented
570572
"EXIF.MINUTE",
571573
"EXIF.SECOND",
572574
"EXIF.MSEC",
@@ -575,12 +577,23 @@ local PLACEHOLDERS = {"ROLL.NAME",
575577
"EXIF.ISO",
576578
"EXIF.EXPOSURE",
577579
"EXIF.EXPOSURE.BIAS",
580+
"EXIF.EXPOSURE.PROGRAM", -- Not Implemented
578581
"EXIF.APERTURE",
579582
"EXIF.CROP.FACTOR",
580583
"EXIF.FOCAL.LENGTH",
581584
"EXIF.FOCAL.LENGTH.EQUIV", -- Not Implemented
582585
"EXIF.FOCUS.DISTANCE",
583-
"IMAGE.EXIF", -- Not Implemented
586+
"EXIF.MAKER",
587+
"EXIF.MODEL",
588+
"EXIF.WHTIEBALANCE", -- Not Implemented
589+
"EXIF.METERING", -- Not Implemented
590+
"EXIF.LENS",
591+
"EXIF.FLASH.ICON", -- Not Implemented
592+
"EXIF.FLASH", -- Not Implemented
593+
"GPS.LONGITUDE", -- Not Implemented
594+
"GPS.LATITUDE", -- Not Implemented
595+
"GPS.ELEVATION", -- Not Implemented
596+
"GPS.LOCATION.ICON", -- Not Implemented
584597
"LONGITUDE",
585598
"LATITUDE",
586599
"ELEVATION",
@@ -589,9 +602,6 @@ local PLACEHOLDERS = {"ROLL.NAME",
589602
"RATING.ICONS", -- Not Implemented
590603
"LABELS",
591604
"LABELS.ICONS", -- Not Implemented
592-
"MAKER",
593-
"MODEL",
594-
"LENS",
595605
"TITLE",
596606
"DESCRIPTION",
597607
"CREATOR",
@@ -692,7 +702,7 @@ end
692702

693703
-- build the argument substitution list from each image
694704

695-
function dtutils_string.build_substitution_list(image, sequence, variable_string, username, pic_folder, home, desktop)
705+
function dtutils_string.build_substitute_list(image, sequence, variable_string, username, pic_folder, home, desktop)
696706
local old_log_level = log.log_level()
697707
log.log_level(dtutils_string.log_level)
698708

@@ -703,6 +713,8 @@ function dtutils_string.build_substitution_list(image, sequence, variable_string
703713
is_api_9_1 = false
704714
end
705715

716+
local is_api_9_4 = dt.configuration.api_version_string >= "9.4.0" and true or false
717+
706718
local datetime = os.date("*t")
707719
local long_month = os.date("%B")
708720
local short_month = os.date("%b")
@@ -753,6 +765,7 @@ function dtutils_string.build_substitution_list(image, sequence, variable_string
753765
short_month, -- MONTH.SHORT
754766
string.format("%02d", datetime.day), -- DAY
755767
string.format("%02d", datetime.hour), -- HOUR
768+
"", -- HOUR.AMPM
756769
string.format("%02d", datetime.min), -- MINUTE
757770
string.format("%02d", datetime.sec), -- SECOND
758771
0, -- MSEC
@@ -763,6 +776,7 @@ function dtutils_string.build_substitution_list(image, sequence, variable_string
763776
os.date("%b", exiftime2systime(image.exif_datetime_taken)), -- EXIF.MONTH.SHORT
764777
eday, -- EXIF.DAY
765778
ehour, -- EXIF.HOUR
779+
"", -- EXIF.HOUR.AMPM
766780
emin, -- EXIF.MINUTE
767781
esec, -- EXIF.SECOND
768782
emsec, -- EXIF.MSEC
@@ -771,12 +785,23 @@ function dtutils_string.build_substitution_list(image, sequence, variable_string
771785
string.format("%d", image.exif_iso), -- EXIF.ISO
772786
string.format("%.0f", 1./image.exif_exposure), -- EXIF.EXPOSURE
773787
image.exif_exposure_bias, -- EXIF.EXPOSURE.BIAS
788+
"", -- EXIF.EXPOSURE.PROGRAM
774789
string.format("%.01f", image.exif_aperture), -- EXIF.APERTURE
775790
string.format("%.01f", image.exif_crop),-- EXIF.CROP_FACTOR
776791
string.format("%.0f", image.exif_focal_length), -- EXIF.FOCAL.LENGTH
777792
string.format("%.0f", image.exif_focal_length * image.exif_crop), -- EXIF.FOCAL.LENGTH.EQUIV
778793
image.exif_focus_distance, -- EXIF.FOCUS.DISTANCE
779-
"", -- IMAGE.EXIF
794+
image.exif_maker, -- EXIF.MAKER
795+
image.exif_model, -- EXIF.MODEL
796+
is_api_9_4 and image.exif_whitebalance or "", -- EXIF.WHITEBALANCE
797+
is_api_9_4 and image.exif_metering_mode or "", -- EXIF.METERING
798+
image.exif_lens, -- LENS
799+
"", -- EXIF.FLASH.ICON
800+
is_api_9_4 and image.exif_flash or "", -- EXIF.FLASH
801+
"", -- GPS.LONGITUDE
802+
"", -- GPS.LATITUDE
803+
"", -- GPS.ELEVATION
804+
"", -- GPS.LOCATION.ICON
780805
image.longitude or "", -- LONGITUDE
781806
image.latitude or "", -- LATITUDE
782807
image.elevation or "", -- ELEVATION
@@ -785,9 +810,6 @@ function dtutils_string.build_substitution_list(image, sequence, variable_string
785810
"", -- RATING.ICONS - wont be implemented
786811
labels, -- LABELS
787812
"", -- LABELS.ICONS - wont be implemented
788-
image.exif_maker, -- MAKER
789-
image.exif_model, -- MODEL
790-
image.exif_lens, -- LENS
791813
image.title, -- TITLE
792814
image.description, -- DESCRIPTION
793815
image.creator, -- CREATOR
@@ -834,84 +856,96 @@ dtutils_string.libdoc.functions["get_substitution_tooltip"] = {
834856
}
835857

836858
function dtutils_string.get_substitution_tooltip()
837-
return string.format("$(ROLL.NAME) - %s\n", _("film roll of the input image")) ..
838-
string.format("$(FILE.FOLDER) - %s\n", _("folder containing the input image")) ..
839-
string.format("$(FILE.NAME) - %s\n", _("basename of the input image")) ..
840-
string.format("$(FILE.EXTENSION) - %s\n", _("extension of the input image")) ..
841-
string.format("$(ID) - %s\n", _("the image id")) ..
842-
string.format("$(VERSION) - %s\n", _("the duplicate version number")) ..
843-
string.format("$(VERSION.IF.MULTI) - %s\n", _("same as $(VERSION) but null string if only one version exists")) ..
844-
string.format("$(VERSION.NAME) - %s\n", _("version name from metadata")) ..
845-
string.format("$(DARKTABLE.VERSION) - %s\n", _("the version of the running darktable instance")) ..
846-
--string.format("$(DARKTABLE.NAME) - %s\n", _("")) .. -- Not Implemented
847-
string.format("$(SEQUENCE[n,m]) - %s\n", _("a sequence number within an export job with n digits and starting with m\nparameters are optional, default is [4,1]")) ..
848-
string.format("$(WIDTH.SENSOR) - %s\n", _("width of RAW data in pixels before RAW crop")) ..
849-
string.format("$(HEIGHT.SENSOR) - %s\n", _("height of RAW data in pixels before RAW crop")) ..
850-
string.format("$(WIDTH.RAW) - %s\n", _("width of RAW data in pixels after RAW crop")) ..
851-
string.format("$(HEIGHT.RAW) - %s\n", _("height of RAW data in pixels after RAW crop")) ..
852-
string.format("$(WIDTH.CROP) - %s\n", _("image width in pixels at the end of the pixelpipe, but before export resize")) ..
853-
string.format("$(HEIGHT.CROP) - %s\n", _("image height in pixels at the end of the pixelpipe, but before export resize")) ..
854-
string.format("$(WIDTH.EXPORT) - %s\n", _("image width in pixels at the end of the pixelpipe and after export resize")) ..
855-
string.format("$(HEIGHT.EXPORT) - %s\n", _("image height in pixels at the end of the pixelpipe and after export resize")) ..
856-
--string.format("$(WIDTH.MAX) - %s\n", _("")) .. -- Not Implemented
857-
--string.format("$(HEIGHT.MAX) - %s\n", _("")) .. -- Not Implemented
858-
string.format("$(YEAR) - %s\n", _("current year")) ..
859-
string.format("$(YEAR.SHORT) - %s\n", _("current two digit year")) ..
860-
string.format("$(MONTH) - %s\n", _("current numeric (1-12) month")) ..
861-
string.format("$(MONTH.LONG) - %s\n", _("full current month name")) ..
862-
string.format("$(MONTH.SHORT) - %s\n", _("abbreviated current month name")) ..
863-
string.format("$(DAY) - %s\n", _("current day")) ..
864-
string.format("$(HOUR) - %s\n", _("current hour")) ..
865-
string.format("$(MINUTE) - %s\n", _("current minute")) ..
866-
string.format("$(SECOND) - %s\n", _("current second")) ..
867-
string.format("$(MSEC) - %s\n", _("current millisecond")) ..
868-
string.format("$(EXIF.YEAR) - EXIF %s\n", _("year")) ..
869-
string.format("$(EXIF.YEAR.SHORT) - EXIF %s\n", _("year, two-digit version")) ..
870-
string.format("$(EXIF.MONTH) - EXIF %s\n", _("month, numeric")) ..
871-
string.format("$(EXIF.MONTH.LONG) - EXIF %s\n", _("month, full name")) ..
872-
string.format("$(EXIF.MONTH.SHORT) - EXIF %s\n", _("month, abbreviated name")) ..
873-
string.format("$(EXIF.DAY) - EXIF %s\n", _("day")) ..
874-
string.format("$(EXIF.HOUR) - EXIF %s\n", _("hour")) ..
875-
string.format("$(EXIF.MINUTE) - EXIF %s\n", _("minute")) ..
876-
string.format("$(EXIF.SECOND) - EXIF %s\n", _("second")) ..
877-
string.format("$(EXIF.MSEC) - EXIF %s\n", _("millisecond")) ..
878-
--string.format("$(EXIF.DATE.REGIONAL) - %s\n", _("")) .. -- Not Implemented
879-
--string.format("$(EXIF.TIME.REGIONAL) - %s\n", _("")) .. -- Not Implemented
880-
string.format("$(EXIF.ISO) - EXIF ISO %s\n", _("value")) ..
881-
string.format("$(EXIF.EXPOSURE) - EXIF %s\n", _("exposure")) ..
882-
string.format("$(EXIF.EXPOSURE.BIAS) - EXIF %s\n", _("exposure bias")) ..
883-
string.format("$(EXIF.APERTURE) - EXIF %s\n", _("aperture")) ..
884-
string.format("$(EXIF.CROP.FACTOR) - EXIF %s\n", _("crop factor")) ..
885-
string.format("$(EXIF.FOCAL.LENGTH) - EXIF %s\n", _("focal length")) ..
886-
string.format("$(EXIF.FOCAL.LENGTH.EQUIV) - EXIF 35mm %s\n", _("equivalent focal length")) .. -- Not Implemented
887-
string.format("$(EXIF.FOCUS.DISTANCE) - EXIF %s\n", _("focus distance")) ..
888-
--string.format("$(IMAGE.EXIF) - %s\n", _("")) .. -- Not Implemented
889-
string.format("$(LONGITUDE) - %s\n", _("longitude")) ..
890-
string.format("$(LATITUDE) - %s\n", _("latitude")) ..
891-
string.format("$(ELEVATION) - %s\n", _("elevation")) ..
892-
--string.format("$(GPS.LOCATION) - %s\n", _("")) .. -- Not Implemented
893-
string.format("$(STARS) - %s\n", _("star rating")) ..
894-
--string.format("$(RATING.ICONS) - %s\n", _("")) .. -- Not Implemented
895-
string.format("$(LABELS) - %s\n", _("colorlabels")) ..
896-
--string.format("$(LABELS.ICONS) - %s\n", _("")) .. -- Not Implemented
897-
string.format("$(MAKER) - %s\n", _("camera maker")) ..
898-
string.format("$(MODEL) - %s\n", _("camera model")) ..
899-
string.format("$(LENS) - %s\n", _("lens")) ..
900-
string.format("$(TITLE) - %s\n", _("title from metadata")) ..
901-
string.format("$(DESCRIPTION) - %s\n", _("description from metadata")) ..
902-
string.format("$(CREATOR) - %s\n", _("creator from metadata")) ..
903-
string.format("$(PUBLISHER) - %s\n", _("publisher from metadata")) ..
904-
string.format("$(RIGHTS) - %s\n", _("rights from metadata")) ..
905-
--string.format("$(TAGS) - %s\n", _("")) .. -- Not Implemented
906-
string.format("$(CATEGORY[n,category]) - %s\n", _("tag name of level n [0,9] of selected category (or tag)")) ..
907-
--string.format("$(SIDECAR.TXT) - %s\n", _("")) .. -- Not Implemented
908-
string.format("$(FOLDER.PICTURES) - %s\n", _("pictures folder")) ..
909-
string.format("$(FOLDER.HOME) - %s\n", _("home folder")) ..
910-
string.format("$(FOLDER.DESKTOP) - %s\n", _("desktop folder")) ..
911-
--string.format("$(OPENCL.ACTIVATED) - %s\n", _("")) .. -- Not Implemented
912-
string.format("$(USERNAME) - %s\n", _("user name defined by OS"))
913-
--string.format("$(NL) - %s\n", _("")) .. -- Not Implemented
914-
--string.format("$(JOBCODE) - %s", _("")) -- Not Implemented
859+
860+
return table.concat({
861+
_("$(ROLL.NAME) - roll of the input image"),
862+
_("$(FILE.FOLDER) - folder containing the input image"),
863+
_("$(FILE.NAME) - basename of the input image"),
864+
_("$(FILE.EXTENSION) - extension of the input image"),
865+
_("$(ID) - image ID"),
866+
_("$(VERSION) - duplicate version"),
867+
_("$(VERSION.IF_MULTI) - same as $(VERSION) but null string if only one version exists"),
868+
_("$(VERSION.NAME) - version name from metadata"),
869+
_("$(DARKTABLE.VERSION) - current darktable version"),
870+
-- _("$(DARKTABLE.NAME) - darktable name"), -- not implemented
871+
_("$(SEQUENCE[n,m]) - sequence number, n: number of digits, m: start number"),
872+
_("$(WIDTH.SENSOR) - image sensor width"),
873+
_("$(HEIGHT.SENSOR) - image sensor height"),
874+
_("$(WIDTH.RAW) - RAW image width"),
875+
_("$(HEIGHT.RAW) - RAW image height"),
876+
_("$(WIDTH.CROP) - image width after crop"),
877+
_("$(HEIGHT.CROP) - image height after crop"),
878+
_("$(WIDTH.EXPORT) - exported image width"),
879+
_("$(HEIGHT.EXPORT) - exported image height"),
880+
-- _("$(WIDTH.MAX) - maximum image export width"), -- not implemented
881+
-- _("$(HEIGHT.MAX) - maximum image export height"), -- not implemented
882+
_("$(YEAR) - year"),
883+
_("$(YEAR.SHORT) - year without century"),
884+
_("$(MONTH) - month"),
885+
_("$(MONTH.LONG) - full month name according to the current locale"),
886+
_("$(MONTH.SHORT) - abbreviated month name according to the current locale"),
887+
_("$(DAY) - day"),
888+
_("$(HOUR) - hour"),
889+
-- _("$(HOUR.AMPM) - hour, 12-hour clock"), -- not implemented
890+
_("$(MINUTE) - minute"),
891+
_("$(SECOND) - second"),
892+
_("$(MSEC) - millisecond"),
893+
_("$(EXIF.YEAR) - EXIF year"),
894+
_("$(EXIF.YEAR.SHORT) - EXIF year without century"),
895+
_("$(EXIF.MONTH) - EXIF month"),
896+
_("$(EXIF.MONTH.LONG) - full EXIF month name according to the current locale"),
897+
_("$(EXIF.MONTH.SHORT) - abbreviated EXIF month name according to the current locale"),
898+
_("$(EXIF.DAY) - EXIF day"),
899+
_("$(EXIF.HOUR) - EXIF hour"),
900+
-- _("$(EXIF.HOUR.AMPM) - EXIF hour, 12-hour clock") .. "\n" .. -- not implemented
901+
_("$(EXIF.MINUTE) - EXIF minute"),
902+
_("$(EXIF.SECOND) - EXIF second"),
903+
_("$(EXIF.MSEC) - EXIF millisecond"),
904+
-- _("$(EXIF.DATE.REGIONAL) - localized EXIF date"), -- not implemented
905+
-- _("$(EXIF.TIME.REGIONAL) - localized EXIF time"), -- not implemented
906+
_("$(EXIF.ISO) - ISO value"),
907+
_("$(EXIF.EXPOSURE) - EXIF exposure"),
908+
_("$(EXIF.EXPOSURE.BIAS) - EXIF exposure bias"),
909+
-- _("$(EXIF.EXPOSURE.PROGRAM) - EXIF exposure program"), -- not implemented
910+
_("$(EXIF.APERTURE) - EXIF aperture"),
911+
_("$(EXIF.CROP_FACTOR) - EXIF crop factor"),
912+
_("$(EXIF.FOCAL.LENGTH) - EXIF focal length"),
913+
_("$(EXIF.FOCAL.LENGTH.EQUIV) - EXIF 35 mm equivalent focal length"),
914+
_("$(EXIF.FOCUS.DISTANCE) - EXIF focal distance"),
915+
_("$(EXIF.MAKER) - camera maker") ..
916+
_("$(EXIF.MODEL) - camera model") ..
917+
_("$(EXIF.WHITEBALANCE) - EXIF selected white balance") .. -- not implemented
918+
_("$(EXIF.METERING) - EXIF exposure metering mode") .. -- not implemented
919+
_("$(EXIF.LENS) - lens") ..
920+
-- _("$(EXIF.FLASH.ICON) - icon indicating whether flash was used") .. -- not implemented
921+
_("$(EXIF.FLASH) - was flash used (yes/no/--)") .. -- not implemented
922+
-- _("$(GPS.LONGITUDE) - longitude"),-- not implemented
923+
-- _("$(GPS.LATITUDE) - latitude"),-- not implemented
924+
-- _("$(GPS.ELEVATION) - elevation"),-- not implemented
925+
-- _("$(GPS.LOCATION.ICON) - icon indicating whether GPS location is known"),-- not implemented
926+
_("$(LONGITUDE) - longitude"),
927+
_("$(LATITUDE) - latitude"),
928+
_("$(ELEVATION) - elevation"),
929+
_("$(STARS) - star rating as number (-1 for rejected)"),
930+
-- _("$(RATING.ICONS) - star/reject rating in icon form"),-- not implemented
931+
_("$(LABELS) - color labels as text"),
932+
-- _("$(LABELS.ICONS) - color labels as icons"),-- not implemented
933+
_("$(TITLE) - title from metadata"),
934+
_("$(DESCRIPTION) - description from metadata"),
935+
_("$(CREATOR) - creator from metadata"),
936+
_("$(PUBLISHER) - publisher from metadata"),
937+
_("$(RIGHTS) - rights from metadata"),
938+
--_("$(TAGS) - tags as set in metadata settings"),
939+
_("$(CATEGORY[n,category]) - subtag of level n in hierarchical tags"),
940+
_("$(SIDECAR_TXT) - contents of .txt sidecar file, if present"),
941+
_("$(FOLDER.PICTURES) - pictures folder"),
942+
_("$(FOLDER.HOME) - home folder"),
943+
_("$(FOLDER.DESKTOP) - desktop folder"),
944+
-- _("$(OPENCL.ACTIVATED) - whether OpenCL is activated"),
945+
_("$(USERNAME) - login name"),
946+
-- _("$(NL) - newline"),
947+
-- _("$(JOBCODE) - job code for import"),
948+
""}, "\n")
915949
end
916950

917951
-- handle different versions of names
@@ -947,6 +981,7 @@ local function treat(var_string)
947981
if string.match(var_string, "CATEGORY%d") or string.match(var_string, "CATEGORY%[") then
948982
log.msg(log.info, "substituting for " .. var_string)
949983
ret_val = substitutes[var_string]
984+
if not ret_val then ret_val = ""
950985
log.msg(log.info, "ret_val is " .. ret_val)
951986

952987
elseif string.match(var_string, "SEQUENCE%[") then

0 commit comments

Comments
 (0)