beta fix for #633, fix face regions in exiftool
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
""" version info """
|
""" version info """
|
||||||
|
|
||||||
__version__ = "0.45.10"
|
__version__ = "0.45.11"
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ class ExportOptions:
|
|||||||
exiftool: (bool, default = False): if True, will use exiftool to write metadata to export file
|
exiftool: (bool, default = False): if True, will use exiftool to write metadata to export file
|
||||||
export_as_hardlink: (bool, default=False): if True, will hardlink files instead of copying them
|
export_as_hardlink: (bool, default=False): if True, will hardlink files instead of copying them
|
||||||
export_db: (ExportDB_ABC): instance of a class that conforms to ExportDB_ABC with methods for getting/setting data related to exported files to compare update state
|
export_db: (ExportDB_ABC): instance of a class that conforms to ExportDB_ABC with methods for getting/setting data related to exported files to compare update state
|
||||||
|
face_regions: (bool, default=True): if True, will export face regions
|
||||||
fileutil: (FileUtilABC): class that conforms to FileUtilABC with various file utilities
|
fileutil: (FileUtilABC): class that conforms to FileUtilABC with various file utilities
|
||||||
force_update: (bool, default=False): if True, will export photo if any metadata has changed but export otherwise would not be triggered (e.g. metadata changed but not using exiftool)
|
force_update: (bool, default=False): if True, will export photo if any metadata has changed but export otherwise would not be triggered (e.g. metadata changed but not using exiftool)
|
||||||
ignore_date_modified (bool): for use with sidecar and exiftool; if True, sets EXIF:ModifyDate to EXIF:DateTimeOriginal even if date_modified is set
|
ignore_date_modified (bool): for use with sidecar and exiftool; if True, sets EXIF:ModifyDate to EXIF:DateTimeOriginal even if date_modified is set
|
||||||
@@ -128,6 +129,7 @@ class ExportOptions:
|
|||||||
exiftool: bool = False
|
exiftool: bool = False
|
||||||
export_as_hardlink: bool = False
|
export_as_hardlink: bool = False
|
||||||
export_db: Optional[ExportDB_ABC] = None
|
export_db: Optional[ExportDB_ABC] = None
|
||||||
|
face_regions: bool = True
|
||||||
fileutil: Optional[FileUtil] = None
|
fileutil: Optional[FileUtil] = None
|
||||||
force_update: bool = False
|
force_update: bool = False
|
||||||
ignore_date_modified: bool = False
|
ignore_date_modified: bool = False
|
||||||
@@ -1539,6 +1541,9 @@ class PhotoExporter:
|
|||||||
person_list = sorted(list(set(person_list)))
|
person_list = sorted(list(set(person_list)))
|
||||||
exif["XMP:PersonInImage"] = person_list.copy()
|
exif["XMP:PersonInImage"] = person_list.copy()
|
||||||
|
|
||||||
|
if options.face_regions and self.photo.face_info and self.photo._db._beta:
|
||||||
|
exif.update(self._get_mwg_face_regions_exiftool())
|
||||||
|
|
||||||
# if self.favorite():
|
# if self.favorite():
|
||||||
# exif["Rating"] = 5
|
# exif["Rating"] = 5
|
||||||
|
|
||||||
@@ -1621,6 +1626,42 @@ class PhotoExporter:
|
|||||||
|
|
||||||
return exif
|
return exif
|
||||||
|
|
||||||
|
def _get_mwg_face_regions_exiftool(self):
|
||||||
|
"""Return a dict with MWG face regions for use by exiftool"""
|
||||||
|
if self.photo.orientation in [5, 6, 7, 8]:
|
||||||
|
w = self.photo.height
|
||||||
|
h = self.photo.width
|
||||||
|
else:
|
||||||
|
w = self.photo.width
|
||||||
|
h = self.photo.height
|
||||||
|
exif = {}
|
||||||
|
exif["XMP:RegionAppliedToDimensionsW"] = w
|
||||||
|
exif["XMP:RegionAppliedToDimensionsH"] = h
|
||||||
|
exif["XMP:RegionAppliedToDimensionsUnit"] = "pixel"
|
||||||
|
exif["XMP:RegionName"] = []
|
||||||
|
exif["XMP:RegionType"] = []
|
||||||
|
exif["XMP:RegionAreaX"] = []
|
||||||
|
exif["XMP:RegionAreaY"] = []
|
||||||
|
exif["XMP:RegionAreaW"] = []
|
||||||
|
exif["XMP:RegionAreaH"] = []
|
||||||
|
exif["XMP:RegionAreaUnit"] = []
|
||||||
|
exif["XMP:RegionPersonDisplayName"] = []
|
||||||
|
# exif["XMP:RegionRectangle"] = []
|
||||||
|
for face in self.photo.face_info:
|
||||||
|
if not face.name:
|
||||||
|
continue
|
||||||
|
area = face.mwg_rs_area
|
||||||
|
exif["XMP:RegionName"].append(face.name)
|
||||||
|
exif["XMP:RegionType"].append("Face")
|
||||||
|
exif["XMP:RegionAreaX"].append(area.x)
|
||||||
|
exif["XMP:RegionAreaY"].append(area.y)
|
||||||
|
exif["XMP:RegionAreaW"].append(area.w)
|
||||||
|
exif["XMP:RegionAreaH"].append(area.h)
|
||||||
|
exif["XMP:RegionAreaUnit"].append("normalized")
|
||||||
|
exif["XMP:RegionPersonDisplayName"].append(face.name)
|
||||||
|
# exif["XMP:RegionRectangle"].append(f"{area.x},{area.y},{area.h},{area.w}")
|
||||||
|
return exif
|
||||||
|
|
||||||
def _get_exif_keywords(self):
|
def _get_exif_keywords(self):
|
||||||
"""returns list of keywords found in the file's exif metadata"""
|
"""returns list of keywords found in the file's exif metadata"""
|
||||||
keywords = []
|
keywords = []
|
||||||
|
|||||||
@@ -103,6 +103,8 @@
|
|||||||
% if photo.face_info:
|
% if photo.face_info:
|
||||||
<mwg-rs:Regions rdf:parseType="Resource">
|
<mwg-rs:Regions rdf:parseType="Resource">
|
||||||
<mwg-rs:AppliedToDimensions rdf:parseType="Resource">
|
<mwg-rs:AppliedToDimensions rdf:parseType="Resource">
|
||||||
|
<stDim:h>${photo.width if photo.orientation in [5, 6, 7, 8] else photo.height}</stDim:h>
|
||||||
|
<stDim:w>${photo.height if photo.orientation in [5, 6, 7, 8] else photo.width}</stDim:w>
|
||||||
<stDim:unit>pixel</stDim:unit>
|
<stDim:unit>pixel</stDim:unit>
|
||||||
</mwg-rs:AppliedToDimensions>
|
</mwg-rs:AppliedToDimensions>
|
||||||
<mwg-rs:RegionList>
|
<mwg-rs:RegionList>
|
||||||
|
|||||||
Reference in New Issue
Block a user