Skip to content

Instantly share code, notes, and snippets.

@NalaGinrut
Created April 24, 2014 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save NalaGinrut/11247771 to your computer and use it in GitHub Desktop.
Save NalaGinrut/11247771 to your computer and use it in GitHub Desktop.
timestamp watermark
#!/usr/bin/python
from PIL import Image, ImageDraw
import time, os, sys
ori, des = sys.argv[1:]
im = Image.open(ori)
draw = ImageDraw.Draw(im)
textPadding = 5
topLeftWidth = int(im.size[0] - (im.size[0] / 4))
topLeftHeight = int(im.size[1] - (im.size[1] / 10))
fileInfo = os.stat(ori)
timeInfo = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(fileInfo.st_mtime))
draw.text([topLeftWidth + textPadding, topLeftHeight + textPadding], timeInfo, fill="red")
im.save(des, 'JPEG', quality=80)
print("Done.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment