Added photoshop:SidecarForExtension to XMP, partial fix for #210

This commit is contained in:
Rhet Turnbull
2020-08-25 21:46:07 -07:00
parent 42e8fba125
commit 60d96a8f56
6 changed files with 25 additions and 5 deletions

View File

@@ -1,3 +1,3 @@
""" version info """
__version__ = "0.33.5"
__version__ = "0.33.6"

View File

@@ -629,7 +629,7 @@ def export2(
logging.debug(f"Skipping missing RAW photo for {filename}")
else:
# use_photo_export
exported = []
exported = []
# export live_photo .mov file?
live_photo = True if live_photo and self.live_photo else False
if edited:
@@ -677,7 +677,7 @@ def export2(
exported_files.extend(exported)
if update:
update_new_files.extend(exported)
else:
logging.warning(
f"Error exporting photo {self.uuid} to {dest} with use_photos_export"
@@ -1127,10 +1127,13 @@ def _xmp_sidecar(
keyword_template: (list of strings); list of template strings to render as keywords
description_template: string; optional template string that will be rendered for use as photo description """
# TODO: add additional fields to XMP file?
xmp_template = Template(filename=os.path.join(_TEMPLATE_DIR, _XMP_TEMPLATE_NAME))
if self.path is not None:
extension = pathlib.Path(self.path).suffix[1:].upper()
else:
extension = None
if description_template is not None:
description = self.render_template(
description_template, expand_inplace=True, inplace_sep=", "
@@ -1199,6 +1202,7 @@ def _xmp_sidecar(
keywords=keyword_list,
persons=person_list,
subjects=subject_list,
extension=extension,
)
# remove extra lines that mako inserts from template

View File

@@ -1,5 +1,13 @@
<!-- Created with osxphotos https://github.com/RhetTbull/osxphotos -->
<%def name="photoshop_sidecar_for_extension(extension)">
% if extension is None:
<photoshop:SidecarForExtension></photoshop:SidecarForExtension>
% else:
<photoshop:SidecarForExtension>${extension}</photoshop:SidecarForExtension>
% endif
</%def>
<%def name="dc_description(desc)">
% if desc is None:
<dc:description></dc:description>
@@ -86,6 +94,7 @@
<rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
${photoshop_sidecar_for_extension(extension)}
${dc_description(description)}
${dc_title(photo.title)}
${dc_subject(subjects)}

View File

@@ -596,6 +596,7 @@ def test_xmp_sidecar():
<rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
<photoshop:SidecarForExtension>JPEG</photoshop:SidecarForExtension>
<dc:description>Girls with pumpkins</dc:description>
<dc:title>Can we carry this?</dc:title>
<!-- keywords and persons listed in <dc:subject> as Photos does -->
@@ -660,6 +661,7 @@ def test_xmp_sidecar_use_persons_keyword():
<rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
<photoshop:SidecarForExtension>JPEG</photoshop:SidecarForExtension>
<dc:description>Girls with pumpkins</dc:description>
<dc:title>Can we carry this?</dc:title>
<!-- keywords and persons listed in <dc:subject> as Photos does -->
@@ -726,6 +728,7 @@ def test_xmp_sidecar_use_albums_keyword():
<rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
<photoshop:SidecarForExtension>JPEG</photoshop:SidecarForExtension>
<dc:description>Girls with pumpkins</dc:description>
<dc:title>Can we carry this?</dc:title>
<!-- keywords and persons listed in <dc:subject> as Photos does -->
@@ -793,6 +796,7 @@ def test_xmp_sidecar_gps():
<rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
<photoshop:SidecarForExtension>JPEG</photoshop:SidecarForExtension>
<dc:description></dc:description>
<dc:title>St. James's Park</dc:title>
<!-- keywords and persons listed in <dc:subject> as Photos does -->

View File

@@ -166,6 +166,7 @@ def test_xmp_sidecar_keyword_template():
<rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
<photoshop:SidecarForExtension>JPEG</photoshop:SidecarForExtension>
<dc:description>Girls with pumpkins</dc:description>
<dc:title>Can we carry this?</dc:title>
<!-- keywords and persons listed in <dc:subject> as Photos does -->

View File

@@ -418,6 +418,7 @@ def test_xmp_sidecar():
<rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
<photoshop:SidecarForExtension>JPG</photoshop:SidecarForExtension>
<dc:description>Girls with pumpkins</dc:description>
<dc:title>Can we carry this?</dc:title>
<!-- keywords and persons listed in <dc:subject> as Photos does -->
@@ -480,6 +481,7 @@ def test_xmp_sidecar_keyword_template():
<rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
<photoshop:SidecarForExtension>JPG</photoshop:SidecarForExtension>
<dc:description>Girls with pumpkins</dc:description>
<dc:title>Can we carry this?</dc:title>
<!-- keywords and persons listed in <dc:subject> as Photos does -->