Fixed steganalysis parity to be compatible with RGBA images

This commit is contained in:
AdrienCos 2019-06-06 21:59:25 -04:00
parent 064456e2a3
commit 2d74094dc3
No known key found for this signature in database
GPG key ID: 97AD9AEBCA16D08D
3 changed files with 10 additions and 1 deletions

View file

@ -31,7 +31,7 @@ def steganalyse(img: Image.Image) -> Image.Image:
""" """
Steganlysis of the LSB technique. Steganlysis of the LSB technique.
""" """
encoded: Image.Image = img.copy() encoded = Image.new(img.mode, (img.size))
width, height = img.size width, height = img.size
for row in range(height): for row in range(height):
for col in range(width): for col in range(width):

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -50,6 +50,15 @@ class TestSteganalysis(unittest.TestCase):
diff = ImageChops.difference(target, analysis).getbbox() diff = ImageChops.difference(target, analysis).getbbox()
self.assertTrue(diff is None) self.assertTrue(diff is None)
def test_parity_rgba(self):
""" Test that stegano.steganalysis.parity works with RGBA images
"""
img = Image.open('./tests/sample-files/transparent.png')
analysis = parity.steganalyse(img)
target = Image.open("./tests/expected-results/parity_rgba.png")
diff = ImageChops.difference(target, analysis).getbbox()
self.assertTrue(diff is None)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()