Skip to content

Commit c966e23

Browse files
Meta_Data_Info_Script added
1 parent 804bfbe commit c966e23

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
from common_utils import menu_utils
5+
import pprintpp # external package
6+
7+
# For images
8+
from PIL.ExifTags import TAGS # external package
9+
from PIL import Image # external package
10+
11+
# For PDFs
12+
from PyPDF2 import PdfFileReader # external package
13+
from PyPDF2 import utils # external package
14+
15+
""" This module uses PILLOW and PyPDF2 in order to retrieve metadata from images and PDFs """
16+
17+
18+
def from_image(image_file):
19+
20+
"""This prints the EXIF info from a given image file"""
21+
22+
try:
23+
image = Image.open(image_file)
24+
exif_image = image._getexif()
25+
26+
menu_utils.header("EXIF info: %s" % image_file)
27+
pprintpp.pprint(exif_image)
28+
29+
if exif_image:
30+
metadata_exif = {}
31+
for (tag,value) in exif_image.items():
32+
decoded = TAGS.get(tag,tag)
33+
metadata_exif[decoded] = value
34+
35+
menu_utils.header("EXIF info detailed %s" % image_file)
36+
37+
for tag in metadata_exif.keys():
38+
menu_utils.mixed_info("[+] %s: " % tag, metadata_exif[tag])
39+
40+
except (FileNotFoundError, OSError) as e:
41+
menu_utils.error(e)
42+
43+
44+
def from_pdf(pdf_file):
45+
46+
"""This prints the metadata from a given PDF"""
47+
48+
try:
49+
pdf = PdfFileReader(pdf_file, 'rb')
50+
51+
# Extracting info from PDF
52+
info_pdf = pdf.getDocumentInfo()
53+
54+
menu_utils.header("Metadata info")
55+
56+
for metadata in info_pdf:
57+
menu_utils.mixed_info("[+] " + metadata + ":", info_pdf[metadata])
58+
59+
except (FileNotFoundError, utils.PdfReadError) as e:
60+
menu_utils.error(e)
61+

Meta_Data_Info_Script/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Meta_Data_Info_Script
2+
3+
Short description of package/script
4+
5+
- This Script Was simple to setup
6+
- Need import PIL, PyPDF2
7+
8+
## Setup instructions
9+
10+
Just Need to Import PIL, PyPDF2 then run the Meta_Data_Info_Script.py file and for running python3 is must be installed!
11+
12+
## Detailed explanation of script, if needed
13+
14+
This Script Is Only for Meta data info checking and use only!
15+
16+
## Author(s)
17+
18+
Kalivarapubindusree

0 commit comments

Comments
 (0)