@@ -0,0 +1,1778 @@
+# -*- coding: utf-8 -*-%0Aimport cv2%0Aimport sys%0Aimport numpy as np%0Afrom PIL import Image, ImageDraw, ImageFont%0Afrom PIL.ExifTags import TAGS, GPSTAGS%0A%0Afont_color = (255, 255, 255)%0A%0Adef get_exif(file,field):%0A    img = Image.open(file)%0A    exif = img._getexif()%0A%0A    exif_data = %5B%5D%0A    for id, value in exif.items():%0A        if TAGS.get(id) == field:%0A            tag = TAGS.get(id, id),value%0A            exif_data.extend(tag)%0A%0A    return exif_data%0A%0Adef get_exif_of_image(file):%0A    im = Image.open(file)%0A%0A    try:%0A        exif = im._getexif()%0A    except AttributeError:%0A        return %7B%7D%0A%0A    exif_table = %7B%7D%0A    for tag_id, value in exif.items():%0A        tag = TAGS.get(tag_id, tag_id)%0A        exif_table%5Btag%5D = value%0A%0A    return exif_table%0A%0Adef get_date_of_image(file):%0A    exif_table = get_exif_of_image(file)%0A    return exif_table.get(%22DateTimeOriginal%22)%0A%0Adef put_date(file, date):%0A    base_img_cv2 = cv2.imread(file)%0A%0A    base_img = Image.open(file).convert('RGBA')%0A    txt = Image.new('RGB', base_img.size, (0, 0, 0))%0A    draw = ImageDraw.Draw(txt)%0A    fnt = ImageFont.truetype('/usr/share/fonts/truetype/freefont/FreeMono.ttf', size=(int)((base_img.size%5B0%5D+base_img.size%5B1%5D)/100))%0A%0A    textw, texth = draw.textsize(date, font=fnt)%0A%0A    draw.text(((base_img.size%5B0%5D*0.95 - textw) , (base_img.size%5B1%5D*0.95 - texth)),%0A              date, font=fnt, fill=font_color)%0A%0A    txt_array = np.array(txt)%0A%0A    output_img = cv2.addWeighted(base_img_cv2, 1.0, txt_array, 1.0, 0)%0A    return output_img%0A%0Aif __name__ == '__main__':%0A    param = sys.argv%0A    if (len(param) != 2):%0A        print (%22Usage: $ python %22 + param%5B0%5D + %22 sample.txt%22)%0A        quit()  %0A%0A    date = get_date_of_image(param%5B1%5D)%0A    output_img = put_date(param%5B1%5D, date)%0A    cv2.imwrite('exifdata_' + param%5B1%5D, output_img)%0A

add script for adding timestamp to photo