In the previous recipe, we saw how to hide text in the
RGBA values of an image. This recipe will let us extract that data out.
We saw in the previous recipe that we split up a characters byte into 8 bits and spread them over the LSBs of two pixels. Here's that diagram again as a refresher:
The following is the script that will do the extraction:
from PIL import Image from itertools import izip def get_pixel_pairs(iterable): a = iter(iterable) return izip(a, a) def get_LSB(value): if value & 1 == 0: return '0' else: return '1' def extract_message(carrier): c_image = Image.open(carrier) pixel_list = list(c_image.getdata()) ...