Quick post!
So this script will take an existing image (so far I’ve only tested it against JPG images) and hide data inside of it!
The way it achieves this is by grabbing the red value of a pixels RGB values, and determines if it is even or odd. For the tool as I’m posting it here, odd = one and even = zero.
This way, you can hide one bit per pixel. So a 1920×1080 image will allow you to embed 253 kilobytes of information. Here’s how:
1920×1080 = 2,073,600 pixels. For this program, each pixel is one bit of data.
2,073,600 bits = 259,200 bytes = 253.125 kilobytes
Note that 253 is the theoretical max. The program as-is ignores red color values of 0 and 255, which may limit how much data is allowed to be embedded.
The script is written in python, and utilizes both numpy and PIL.
import numpy as np import Image ################# GET INPUT input_as_bits = [] with open('E:\\test_input.txt','rb') as f: test_input = bytearray(f.read()) for n in test_input: input_as_bits.append(bin(n)[2:].rjust(8,'0')) input_as_bits = ''.join(input_as_bits) ################# END FUNC image_file = Image.open('E:\\basefile3.jpg') r,g,b = np.array(image_file).transpose() input_count = 0 for row_count,row in enumerate(r): for column_count,pixel_value in enumerate(row): if pixel_value > 0 and pixel_value < 255: try: if input_as_bits[input_count]: #This means the bit to add is odd if not pixel_value%2: #This means the byte is even and we want odd r[row_count][column_count] += 1 print('Changed: ' + str(row_count) + ':' + str(column_count)) else: #This means the bit to add is even if pixel_value%2: r[row_count][column_count] += 1 print('Changed: ' + str(row_count) + ':' + str(column_count)) input_count += 1 print(input_count) except: pass #End of input_as_bits im = Image.fromarray(np.dstack([item.transpose() for item in (r,g,b)])) im.save('E:\\output.jpg')