Created
April 22, 2015 08:59
-
-
Save axiaoxin/9e9fe3696ce12ed1ade1 to your computer and use it in GitHub Desktop.
hide info in pic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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