-
-
Notifications
You must be signed in to change notification settings - Fork 99
/
mkimg.py
65 lines (51 loc) · 1.35 KB
/
mkimg.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -------------------------
# (c) kelu124
# cc-by-sa/4.0/
#
# Library for creating images from the
# files created by pulser module.
# Used in `20180809b`
# Definitely not optimized
#
# -------------------------
'''Description: Autotagging images for the `20180506a` experiment.'''
__author__ = "kelu124"
__copyright__ = "Copyright 2018, Kelu124"
__license__ = "cc-by-sa/4.0/"
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'
Imgs = []
for dirpath, dirnames, filenames in os.walk("."):
for filename in [f for f in filenames if ( f.endswith(".jpg") or f.endswith(".png") )]:
Imgs.append( os.path.join(dirpath, 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'] = "ausonics75"
# Experiment
metadata['Exif.Image.Make'] = "20180809b"
metadata['Exif.Photo.MakerNote'] = "teardown"
# Description
metadata['Exif.Image.ImageDescription'] = "ausonic 7.5MHz probe"
# Saving the image
metadata.write()
print "Image "+FileName+" saved"