mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-05-12 17:18:30 +02:00
add optional auto_convert_rgb parameter to slsb.hide/slsbset.hide; add .idea to .gitignore
This commit is contained in:
parent
75b41a2e2e
commit
a38f23509b
3 changed files with 16 additions and 13 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -6,6 +6,8 @@ syntax: glob
|
|||
*~
|
||||
*.db
|
||||
|
||||
.idea/
|
||||
|
||||
build/*
|
||||
Stegano.egg-info/*
|
||||
dist/*
|
||||
|
|
|
@ -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,12 +43,12 @@ def hide(input_image_file, message):
|
|||
img = Image.open(input_image_file)
|
||||
|
||||
if img.mode != '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')
|
||||
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.')
|
||||
img = img.convert('RGB')
|
||||
|
||||
encoded = img.copy()
|
||||
width, height = img.size
|
||||
|
|
|
@ -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,11 +45,12 @@ 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))
|
||||
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')
|
||||
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.')
|
||||
|
||||
img = img.convert('RGB')
|
||||
|
||||
img_list = list(img.getdata())
|
||||
width, height = img.size
|
||||
|
|
Loading…
Add table
Reference in a new issue