Implement metadata fetching

This commit is contained in:
Fred Boniface 2023-11-04 22:29:00 +00:00
parent 991e1d47e6
commit 2f8de442f2
6 changed files with 31 additions and 1 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
include
bin
# ---> Python # ---> Python
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/

View File

@ -1,4 +1,4 @@
Copyright (c) <year> <owner>. 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: Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

21
image_processing.py Normal file
View File

@ -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)

1
lib64 Symbolic link
View File

@ -0,0 +1 @@
lib

0
main.py Normal file
View File

5
pyvenv.cfg Normal file
View File

@ -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