mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-05-12 17:18:30 +02:00
Merge pull request #3 from papercapp/master
add optional auto_convert_rgb parameter to slsb.hide/slsbset.hide; ad…
This commit is contained in:
commit
d869dadcc0
3 changed files with 16 additions and 13 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -6,6 +6,8 @@ syntax: glob
|
||||||
*~
|
*~
|
||||||
*.db
|
*.db
|
||||||
|
|
||||||
|
.idea/
|
||||||
|
|
||||||
build/*
|
build/*
|
||||||
Stegano.egg-info/*
|
Stegano.egg-info/*
|
||||||
dist/*
|
dist/*
|
||||||
|
|
|
@ -35,7 +35,7 @@ try:
|
||||||
except NameError:
|
except NameError:
|
||||||
pass
|
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
|
Hide a message (string) in an image with the
|
||||||
LSB (Least Significant Bit) technique.
|
LSB (Least Significant Bit) technique.
|
||||||
|
@ -43,12 +43,12 @@ def hide(input_image_file, message):
|
||||||
img = Image.open(input_image_file)
|
img = Image.open(input_image_file)
|
||||||
|
|
||||||
if img.mode != 'RGB':
|
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'
|
print('The mode of the image is not RGB. Mode is {}'.format(img.mode))
|
||||||
if answer.lower() == 'n':
|
answer = input('Convert the image to RGB ? [Y / n]\n') or 'Y'
|
||||||
raise Exception('Not a RGB image.')
|
if answer.lower() == 'n':
|
||||||
else:
|
raise Exception('Not a RGB image.')
|
||||||
img = img.convert('RGB')
|
img = img.convert('RGB')
|
||||||
|
|
||||||
encoded = img.copy()
|
encoded = img.copy()
|
||||||
width, height = img.size
|
width, height = img.size
|
||||||
|
|
|
@ -36,7 +36,7 @@ try:
|
||||||
except NameError:
|
except NameError:
|
||||||
pass
|
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
|
Hide a message (string) in an image with the
|
||||||
LSB (Least Significant Bit) technique.
|
LSB (Least Significant Bit) technique.
|
||||||
|
@ -45,11 +45,12 @@ def hide(input_image_file, message, generator_function):
|
||||||
|
|
||||||
if img.mode != 'RGB':
|
if img.mode != 'RGB':
|
||||||
print('The mode of the image is not RGB. Mode is {}'.format(img.mode))
|
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 not auto_convert_rgb:
|
||||||
if answer.lower() == 'n':
|
answer = input('Convert the image to RGB ? [Y / n]\n') or 'Y'
|
||||||
raise Exception('Not a RGB image.')
|
if answer.lower() == 'n':
|
||||||
else:
|
raise Exception('Not a RGB image.')
|
||||||
img = img.convert('RGB')
|
|
||||||
|
img = img.convert('RGB')
|
||||||
|
|
||||||
img_list = list(img.getdata())
|
img_list = list(img.getdata())
|
||||||
width, height = img.size
|
width, height = img.size
|
||||||
|
|
Loading…
Add table
Reference in a new issue