mirror of
https://github.com/metafy-social/python-scripts.git
synced 2024-11-27 14:01:12 +00:00
added image metadata extractor script
This commit is contained in:
parent
618f2fd966
commit
04f5d77cf0
7
scripts/image_metadata_extractor/README.md
Normal file
7
scripts/image_metadata_extractor/README.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# Image Metadata Extractor
|
||||||
|
A simple script that extracts metadata from images
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
* Dependencies:
|
||||||
|
Pillow
|
||||||
|
* Get started using `pip install -r requirements.txt`
|
1
scripts/image_metadata_extractor/requirements.txt
Normal file
1
scripts/image_metadata_extractor/requirements.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pillow
|
22
scripts/image_metadata_extractor/script.py
Normal file
22
scripts/image_metadata_extractor/script.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
from PIL import Image
|
||||||
|
from PIL.ExifTags import TAGS
|
||||||
|
import sys
|
||||||
|
|
||||||
|
arg = sys.argv[1]
|
||||||
|
if arg == "":
|
||||||
|
print("Please give a valid image path")
|
||||||
|
quit()
|
||||||
|
|
||||||
|
image = Image.open(arg)
|
||||||
|
exifdata = image.getexif()
|
||||||
|
|
||||||
|
if len(exifdata) <= 0:
|
||||||
|
print("No metadata found for this image")
|
||||||
|
quit()
|
||||||
|
|
||||||
|
for tag_id in exifdata:
|
||||||
|
|
||||||
|
tagname = TAGS.get(tag_id, tag_id)
|
||||||
|
value = exifdata.get(tag_id)
|
||||||
|
|
||||||
|
print(f"{tagname:25}: {value}")
|
Loading…
Reference in New Issue
Block a user