diff --git a/.version b/.version index 9aa3464..5588ae8 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -2.7.0 \ No newline at end of file +2.7.1 \ No newline at end of file diff --git a/README.md b/README.md index 2e52fc1..b7e80c5 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ To generate a web manifest file: - The script generates the preview thumbnails in a `.thumbnails` subdirectory within the root folder. - The `.lock` file prevents multiple instances of the script from running simultaneously. Make sure to remove it if the script terminates unexpectedly. - Add a `info` file into any directory containing pictures and it will be read and displayed as a tooltip on the website. -- Add tags to the Image exif or to `.metadata.json` to tag images for filtering. +- Add tags to the Image xmp `subject` or to `.metadata.json` to tag images for filtering. ## License diff --git a/modules/generate_html.py b/modules/generate_html.py index 2a8925d..02dcfe3 100644 --- a/modules/generate_html.py +++ b/modules/generate_html.py @@ -100,12 +100,14 @@ def get_image_info(item: str, folder: str) -> dict[str, Any]: try: with Image.open(file) as img: logger.info("extracting image information", extra={"file": file}) - exif = img.getexif() width, height = img.size + exif = img.getexif() + xmp = img.getxmp() + except UnidentifiedImageError: logger.error("cannot identify image file", extra={"file": file}) print(f"cannot identify image file: {file}") - return {"width": None, "height": None, "tags": None, "exifdata": None} + return {"width": None, "height": None, "tags": None, "exifdata": None, "xmp": None} if exif: logger.info("extracting EXIF data", extra={"file": file}) ifd = exif.get_ifd(ExifTags.IFD.Exif) @@ -141,9 +143,14 @@ def get_image_info(item: str, folder: str) -> dict[str, Any]: for key in ["PrintImageMatching", "UserComment", "MakerNote"]: if key in exifdata: del exifdata[key] - return {"width": width, "height": height, "tags": [], "exifdata": exifdata} else: - return {"width": width, "height": height, "tags": [], "exifdata": None} + exifdata = None + if xmp["xmpmeta"]["RDF"]["Description"].get("subject", False): + tags = xmp["xmpmeta"]["RDF"]["Description"]["subject"]["Bag"]["li"] + else: + tags = [] + xmp = None + return {"width": width, "height": height, "tags": tags, "exifdata": exifdata, "xmp": xmp} def process_image(item: str, folder: str, _args: Args, baseurl: str, metadata: dict[str, dict[str, int]], raw: list[str]) -> dict[str, Any]: @@ -173,6 +180,7 @@ def process_image(item: str, folder: str, _args: Args, baseurl: str, metadata: d "height": metadata[item]["height"], "tags": metadata[item]["tags"], "exifdata": metadata[item].get("exifdata", ""), + "xmp": metadata[item].get("xmp", ""), } path = os.path.join(_args.root_directory, ".thumbnails", baseurl, item + ".jpg") if not os.path.exists(path) or _args.regenerate_thumbnails: diff --git a/test/example/DSC00009.jpg b/test/example/DSC00009.jpg new file mode 100644 index 0000000..a228610 Binary files /dev/null and b/test/example/DSC00009.jpg differ diff --git a/test/example/DSC01106.jpg b/test/example/DSC01106.jpg new file mode 100644 index 0000000..5f64640 Binary files /dev/null and b/test/example/DSC01106.jpg differ diff --git a/test/example/license.html b/test/example/license.html index d60db59..bc33b81 100644 --- a/test/example/license.html +++ b/test/example/license.html @@ -460,7 +460,7 @@ Creative Commons may be contacted at creativecommons.org.
- Made with StaticGalleryBuilder 2.7.0 by Made with StaticGalleryBuilder 2.7.1 by sorogon </srgn> .