-
Quick question... As I export my Photos library to Synology Photos which does not recognise the RegionName (faces) I'm adding them to keywords with "person:" prefix. I could use My
exiftool_merge_keywords = true
exiftool_merge_persons = true
keyword_template = [
"{var:empty,}{var:name1,Person1}{var:name2,Person2}{person|sort matches {%name1}|{%name2}?person:{person},{%empty}}",
] I guess I must go thru the list of persons and processed them one by one... maybe with the use of an external python function? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Testing out with the filter example function and it works!!! Hopefully will not delay much the export ;) TOML fileexiftool = true
exiftool_merge_keywords = true
exiftool_merge_persons = true
keyword_template = [
"{person|sort|function:persons.py::myfilter}",
] Python file:""" Example of using a custom python function as an osxphotos template filter
Use in formath:
"{template_field|template_filter.py::myfilter}"
Your filter function will receive a list of strings even if the template renders to a single value.
You should expect a list and return a list and be able to handle multi-value templates like {keyword}
as well as single-value templates like {original_name}
"""
from typing import List
def myfilter(values: List[str]) -> List[str]:
"""Custom filter to add keywords for filtered persons
filtered_persons = ["Person1", "Person2", "Person3", "Person4"] # Persons to include in the list
values = ["person:" + person for person in values if person in filtered_persons]
return values
# Example usage #1:
# input_strings = ["apple", "Person1", "orange", "Person3", "kiwi"]
# result = myfilter(input_strings)
# print(result)
# Example usage #2:
# input_strings = ["apple", "orange", "kiwi"]
# result = myfilter(input_strings)
# print(result) |
Beta Was this translation helpful? Give feedback.
Testing out with the filter example function and it works!!! Hopefully will not delay much the export ;)
TOML file
Python file: