Skip to content

Instantly share code, notes, and snippets.

@axiaoxin
Created April 22, 2015 08:59
Show Gist options
  • Save axiaoxin/9e9fe3696ce12ed1ade1 to your computer and use it in GitHub Desktop.
Save axiaoxin/9e9fe3696ce12ed1ade1 to your computer and use it in GitHub Desktop.
hide info in pic
import stepic
from PIL import Image
import sys
useage = 'useage:\nencode: python hideinfo.py IMG INFO OUTPUT\ndecode: python hideinfo.py IMG'
def encode_img(img, info, output):
img = Image.open(img)
d = open(info)
info = d.read()
d.close()
img = stepic.encode(img, info)
img.save(output)
def decode_img(img):
img = Image.open(img)
print stepic.decode(img)
if len(sys.argv) == 2:
decode_img(sys.argv[1])
elif len(sys.argv) == 4:
encode_img(sys.argv[1], sys.argv[2], sys.argv[3])
else:
print useage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment