-
-
Notifications
You must be signed in to change notification settings - Fork 99
/
img.py
57 lines (43 loc) · 1.15 KB
/
img.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
#!/usr/bin/python
import sys
import pyexiv2
import os
# For experiment `20171124a`
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'
Imgs = []
for filename in os.listdir("./"):
if filename.endswith(".jpg"):
Imgs.append(os.path.join("./", filename))
if filename.endswith(".png"):
Imgs.append(os.path.join("./", filename))
print Imgs
for FileName in Imgs:
edit = 0
metadata = pyexiv2.ImageMetadata(FileName)
try:
metadata.read()
except IOError:
print "Not an image"
else:
# Modules
metadata['Exif.Image.Software'] = "oneeye, croaker, tobo, doj, goblin, cletus"
# Description
metadata['Exif.Image.ImageDescription'] = "Images from the experiment 20171124a"
# Experiment
metadata['Exif.Image.Make'] = "20171124a"
# Type of picture
if FileName.startswith("_o"):
metadata['Exif.Photo.MakerNote'] = "graph"
if FileName.startswith("2017"):
metadata['Exif.Photo.MakerNote'] = "setup"
# Saving the image
metadata.write()
print "Image "+FileName+" saved"