From 1ff2f9c7c063d8731c3285269704d956c0442380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bonhomme?= Date: Sun, 13 Mar 2016 00:34:46 +0100 Subject: [PATCH] Closes #2. --- stegano/slsb.py | 9 +++++++++ stegano/slsbset.py | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/stegano/slsb.py b/stegano/slsb.py index 8eb35ce..359a892 100755 --- a/stegano/slsb.py +++ b/stegano/slsb.py @@ -36,6 +36,15 @@ def hide(input_image_file, message): LSB (Least Significant Bit) technique. """ 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') + if answer == 'n': + raise Exception('Not a RGB image.') + else: + img = img.convert('RGB') + encoded = img.copy() width, height = img.size index = 0 diff --git a/stegano/slsbset.py b/stegano/slsbset.py index 417f825..28772ba 100644 --- a/stegano/slsbset.py +++ b/stegano/slsbset.py @@ -37,6 +37,15 @@ def hide(input_image_file, message, generator_function): LSB (Least Significant Bit) technique. """ 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') + if answer == 'n': + raise Exception('Not a RGB image.') + else: + img = img.convert('RGB') + img_list = list(img.getdata()) width, height = img.size index = 0