#! /usr/bin/python # -*- coding: utf-8 -*- from PIL import Image import sys # open INPUT.png as RGBA im = Image.open("INPUT.png").convert(mode="RGBA") width, height = im.size # go through the image and extract the lowest bit # for each RGB component and set it to all other bits pix = im.load() for x in range(0, width): for y in range(0, height): rgba = pix[x, y] if (rgba[0] & 1) == 1: r = 255 else: r = 0 if (rgba[1] & 1) == 1: g = 255 else: g = 0 if (rgba[2] & 1) == 1: b = 255 else: b = 0 pix[x, y] = (r,g,b,255) im.save("test.png")