Python 2 compatibility for exifHeader.

This commit is contained in:
Cédric Bonhomme 2016-05-26 07:18:56 +02:00
parent 1def5672ab
commit fef2040fca
No known key found for this signature in database
GPG key ID: A1CB94DE57B7A70D
4 changed files with 26 additions and 12 deletions

View file

@ -20,8 +20,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>
__author__ = "Cedric Bonhomme"
__version__ = "$Revision: 0.2 $"
__date__ = "$Date: 2016/05/17 $"
__version__ = "$Revision: 0.2.1 $"
__date__ = "$Date: 2016/05/26 $"
__license__ = "GPLv3"
from PIL import Image
@ -36,10 +36,12 @@ def hide(input_image_file, img_enc, secret_message = None, secret_file = None):
if secret_file != None:
with open(secret_file, "r") as f:
secret_file_content = f.read()
text = compress(b64encode(bytes(secret_file_content, "utf-8")))
else:
secret_message = f.read()
try:
text = compress(b64encode(bytes(secret_message, "utf-8")))
except:
text = compress(b64encode(secret_message))
img = Image.open(input_image_file)
if "exif" in img.info: