Merge pull request #3 from papercapp/master

add optional auto_convert_rgb parameter to slsb.hide/slsbset.hide; ad…
This commit is contained in:
Cédric Bonhomme 2016-04-21 22:11:15 +02:00
commit d869dadcc0
3 changed files with 16 additions and 13 deletions

2
.gitignore vendored
View file

@ -6,6 +6,8 @@ syntax: glob
*~
*.db
.idea/
build/*
Stegano.egg-info/*
dist/*

View file

@ -35,7 +35,7 @@ try:
except NameError:
pass
def hide(input_image_file, message):
def hide(input_image_file, message, auto_convert_rgb=False):
"""
Hide a message (string) in an image with the
LSB (Least Significant Bit) technique.
@ -43,11 +43,11 @@ def hide(input_image_file, message):
img = Image.open(input_image_file)
if img.mode != 'RGB':
if not auto_convert_rgb:
print('The mode of the image is not RGB. Mode is {}'.format(img.mode))
answer = input('Convert the image to RGB ? [Y / n]\n') or 'Y'
if answer.lower() == 'n':
raise Exception('Not a RGB image.')
else:
img = img.convert('RGB')
encoded = img.copy()

View file

@ -36,7 +36,7 @@ try:
except NameError:
pass
def hide(input_image_file, message, generator_function):
def hide(input_image_file, message, generator_function, auto_convert_rgb=False):
"""
Hide a message (string) in an image with the
LSB (Least Significant Bit) technique.
@ -45,10 +45,11 @@ def hide(input_image_file, message, generator_function):
if img.mode != 'RGB':
print('The mode of the image is not RGB. Mode is {}'.format(img.mode))
if not auto_convert_rgb:
answer = input('Convert the image to RGB ? [Y / n]\n') or 'Y'
if answer.lower() == 'n':
raise Exception('Not a RGB image.')
else:
img = img.convert('RGB')
img_list = list(img.getdata())