tsoxmas

LSB ozsh

Aug 20th, 2019
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. from PIL import Image
  2.  
  3. f = [
  4.     '01100110011011000110000101100111001110100110001101101111011011110110110001011111011100000110100101101100011011000110111101110111']
  5.  
  6.  
  7. def lsb():
  8.     pic = Image.open('image1.jpg')
  9.     x, y = pic.size
  10.     pic2 = Image.new('RGB', (x, y))
  11.     pixels = pic.load()
  12.     pixels2 = pic2.load()
  13.     count = 0
  14.     for i in range(x):
  15.         for j in range(y):
  16.             r, g, b = pixels[i, j]
  17.             #print(r)
  18.             if count < len(f[0]):
  19.                 #print(bin(r)[2:-1])
  20.                 r = int(bin(r)[2:-1] + f[0][count], 2)
  21.                 #print(r, 'new')
  22.             pixels2[i, j] = (r, g, b)
  23.             count += 1
  24.  
  25.     pic2.save('res.jpg')
  26.  
  27.  
  28. lsb()
Add Comment
Please, Sign In to add comment