Skip to content

Instantly share code, notes, and snippets.

@fabienhinault
Last active August 29, 2015 14:00
Show Gist options
  • Save fabienhinault/57c8c5f6631323488e7a to your computer and use it in GitHub Desktop.
Save fabienhinault/57c8c5f6631323488e7a to your computer and use it in GitHub Desktop.
from PIL import Image
import PIL.ImageOps
import glob
for f in glob.glob('./*.bmp'):
image = Image.open(f).convert("RGB")
inverted_image = PIL.ImageOps.invert(image)
inverted_image.save(f)
from PIL import Image
import PIL.ImageOps
import glob
orange = (255,102,0)
blue =(30,86,160)
for f in glob.glob('./*.bmp'):
img = Image.open(f).convert("RGB")
pixdata = img.load()
for y in xrange(img.size[1]):
for x in xrange(img.size[0]):
pix = pixdata[x, y]
delta = (pix[0] - orange[0], pix[1] - orange[1],
pix[2] - orange[2])
maxdelta = sum(abs(d) for d in delta)
if maxdelta < 300:
pixdata[x, y] = (blue[0] + delta[0],
blue[1] + delta[1],
blue[2] + delta[2])
img.save(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment