Skip to content

Instantly share code, notes, and snippets.

@wgaylord
Created April 24, 2017 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wgaylord/b11143da53a9a14edd3a9ac156290905 to your computer and use it in GitHub Desktop.
Save wgaylord/b11143da53a9a14edd3a9ac156290905 to your computer and use it in GitHub Desktop.
ImageMaker.py
from PIL import Image
def fix(pixel,d):
r =pixel[0]
g=pixel[1]
b=pixel[2]
factor=d/((r+b+g)/4.0)
return (int(r*factor),int(g*factor),int(b*factor))
def make(bw,color,size,scale):
t = Image.new('RGB',size)
for x in range(size[0]):
for y in range(size[1]):
try:
r=color.getpixel((x/scale,y/scale))
t.putpixel((x,y),fix(r,bw.getpixel((x,y))))
except:
print 'Bad Size on ',x,y
return t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment