Skip to content

Commit d9cb8b7

Browse files
authored
Update image_metadata_extractor.py
Added a dictionary to iterate through all other potential metadata
1 parent a747c1f commit d9cb8b7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

ethical-hacking/image-metadata-extractor/image_metadata_extractor.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
# read the image data using PIL
99
image = Image.open(imagename)
1010

11+
#extract other metadata
12+
info_dict={"Filename":image.filename,
13+
"Image Size":image.size,
14+
"Image Height":image.height,
15+
"Image Width":image.width,
16+
"Image Format":image.format,
17+
"Image Mode":image.mode,
18+
"Image is Animated": getattr(image, "is_animated", False),
19+
"Frames in Image":getattr(image, "n_frames", 1)
20+
}
21+
for label,value in info_dict.items():
22+
print(f"{label:25}: {value}")
23+
1124
# extract EXIF data
1225
exifdata = image.getexif()
1326

@@ -19,4 +32,4 @@
1932
# decode bytes
2033
if isinstance(data, bytes):
2134
data = data.decode()
22-
print(f"{tag:25}: {data}")
35+
print(f"{tag:25}: {data}")

0 commit comments

Comments
 (0)