From 2f8de442f230f4890497db36f3d40a5a8b2bc62d Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Sat, 4 Nov 2023 22:29:00 +0000 Subject: [PATCH] Implement metadata fetching --- .gitignore | 3 +++ LICENSE | 2 +- image_processing.py | 21 +++++++++++++++++++++ lib64 | 1 + main.py | 0 pyvenv.cfg | 5 +++++ 6 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 image_processing.py create mode 120000 lib64 create mode 100644 main.py create mode 100644 pyvenv.cfg diff --git a/.gitignore b/.gitignore index 5d381cc..2e5d66a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +include +bin + # ---> Python # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/LICENSE b/LICENSE index 4005b63..0182938 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) . All rights reserved. +Copyright (c) 2023 Frederick Boniface. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/image_processing.py b/image_processing.py new file mode 100644 index 0000000..94a56bf --- /dev/null +++ b/image_processing.py @@ -0,0 +1,21 @@ +import pyexiv2 + +def get_image_data(path: str): + img = pyexiv2.Image(path) + xmp = img.read_xmp() + create_date = xmp.get('Xmp.xmp.CreateDate', 'N/A') + title = xmp.get('Xmp.dc.title', 'N/A') + description = xmp.get('Xmp.dc.description', 'N/A') + tags = xmp.get('Xmp.dc.subject', 'N/A') + description_parts = description['lang="x-default"'].split('|') + main_description = description_parts[0].strip() + alt_text = description_parts[1].strip() + image_data = { + 'path': path, + 'create': create_date + "Z", + 'title': title['lang="x-default"'], + 'description': main_description, + 'alt': alt_text, + 'tags': tags + } + print(image_data) diff --git a/lib64 b/lib64 new file mode 120000 index 0000000..7951405 --- /dev/null +++ b/lib64 @@ -0,0 +1 @@ +lib \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..e69de29 diff --git a/pyvenv.cfg b/pyvenv.cfg new file mode 100644 index 0000000..b491139 --- /dev/null +++ b/pyvenv.cfg @@ -0,0 +1,5 @@ +home = /usr/bin +include-system-site-packages = false +version = 3.11.6 +executable = /usr/bin/python3.11 +command = /usr/bin/python -m venv /home/fred.boniface/git/social-photos