Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/numbersprotocol/pyxmp
A Python XMP metadata injection tool based on py3exiv2
https://github.com/numbersprotocol/pyxmp
Last synced: about 2 months ago
JSON representation
A Python XMP metadata injection tool based on py3exiv2
- Host: GitHub
- URL: https://github.com/numbersprotocol/pyxmp
- Owner: numbersprotocol
- License: gpl-3.0
- Created: 2020-10-21T07:28:53.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-10-22T08:34:51.000Z (about 4 years ago)
- Last Synced: 2024-10-29T01:13:05.864Z (about 2 months ago)
- Language: Python
- Size: 23.4 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pyxmp
A Python XMP metadata injection tool based on py3exiv2## Installation
```
python -m pip install pyxmp
```## Usage
To inject XMP metadata to the image, the input metadata should be a list of dict following the format below, with `provider`, `name` and `value` as keys.
```
[
{
"provider": "InfoSnapshot",
"name": "Brand",
"value": "My Service"
},
{
"provider": "InfoSnapshot",
"name": "Current GPS Accuracy",
"value": "14.589"
},
{
"provider": "InfoSnapshot",
"name": "Current GPS Latitude",
"value": "25.045234"
},
{
"provider": "InfoSnapshot",
"name": "Current GPS Longitude",
"value": "121.530795"
},
{
"provider": "InfoSnapshot",
"name": "Current GPS Timestamp",
"value": "2020-09-15T13:50:25.143Z"
},
{
"provider":"InfoSnapshot",
"name":"Timestamp",
"value":"2020-09-15T13:50:30.203Z"
}
]
```Then the metadata could be injected like the following example:
```
import pyxmpmetadata = {...} # Prepare the metadata like the above example
xmp_injected_image = pyxmp.inject(
original_image_bytes,
metadata,
'http://numbersprotocol.io/xmp/',
'examplePrefix'
)
```To read the XMP metadata into a dict:
```
import pyxmpmetadata_dict = pyxmp.read(xmp_injected_image)
```Example injected XMP metadata dict:
```
{
'Xmp.examplePrefix.infoSnapshot.brand': 'My Service',
'Xmp.examplePrefix.infoSnapshot.currentGPSAccuracy': '14.589',
'Xmp.examplePrefix.infoSnapshot.currentGPSLatitude': '25.045234',
'Xmp.examplePrefix.infoSnapshot.currentGPSLongitude': '121.530795',
'Xmp.examplePrefix.infoSnapshot.currentGPSTimestamp': '2020-09-15T13:50:25.143Z',
'Xmp.examplePrefix.infoSnapshot.timestamp': '2020-09-15T13:50:30.203Z'
}
```