Created
April 24, 2017 20:28
-
-
Save wgaylord/b11143da53a9a14edd3a9ac156290905 to your computer and use it in GitHub Desktop.
ImageMaker.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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