-
-
Notifications
You must be signed in to change notification settings - Fork 99
/
et.py
84 lines (72 loc) · 2.22 KB
/
et.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/python
import sys
import pyexiv2
import os
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
print( 'Number of arguments:', len(sys.argv), 'arguments.')
print( 'Argument List:', str(sys.argv))
edit = 0
if (len(sys.argv) == 2 ):
FileName = sys.argv[1]
if not os.path.exists(FileName):
print( "FileDoesNotExist")
else:
metadata = pyexiv2.ImageMetadata(FileName)
try:
metadata.read()
except IOError:
print( "Not an image")
else:
# Modules
print( "Already here -> " + bcolors.WARNING + str(metadata['Exif.Image.Software'].value) + bcolors.ENDC)
input_var = str(input("What modules are present (enter = pass): "))
if len(input_var):
edit = 1
#print "You entered: " + input_var
metadata['Exif.Image.Software'] = input_var
# Description
print( "Already here -> " + bcolors.WARNING + str(metadata['Exif.Image.ImageDescription'].value) + bcolors.ENDC)
input_var = str(input("Description? (enter = pass): "))
if len(input_var):
edit = 1
#print "You entered: " + input_var
metadata['Exif.Image.ImageDescription'] = input_var
if edit:
metadata.write()
print("Image saved")
# Experiment
try:
metadata['Exif.Image.Make'].value
except KeyError:
metadata['Exif.Image.Make'] = ""
print( "Already here -> " + bcolors.WARNING + str(metadata['Exif.Image.Make'].value) + bcolors.ENDC)
input_var = str(input("Experiment? (enter = pass): "))
if len(input_var):
edit = 1
#print "You entered: " + input_var
metadata['Exif.Image.Make'] = input_var
# Type of picture
try:
metadata['Exif.Photo.MakerNote'].value
except KeyError:
metadata['Exif.Photo.MakerNote'].value = ""
print ("Already here -> " + bcolors.WARNING + str(metadata['Exif.Photo.MakerNote'].value) + bcolors.ENDC)
input_var = str(input("Type of picture? (enter = pass): "))
if len(input_var):
edit = 1
#print "You entered: " + input_var
metadata['Exif.Photo.MakerNote'] = input_var
# Saving the image
if edit:
metadata.write()
print ("Image saved")
else:
print( "No file passed")