Created
September 6, 2011 08:59
-
-
Save sneeu/1197026 to your computer and use it in GitHub Desktop.
Upscale an image to double with & height, and put a dithering pattern over it.
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 dither(im): | |
width, height = im.size | |
avg_color = tuple([n / 2 for n in sorted(im.getcolors(width * height))[-1][1]]) | |
new_im = Image.new("RGBA", (width * 2, height * 2), avg_color) | |
for x in xrange(0, width): | |
for y in xrange(0, height): | |
new_im.putpixel((x * 2, y * 2), im.getpixel((x, y))) | |
return new_im | |
if __name__ == '__main__': | |
im = Image.open('unknown.jpg') | |
new_im = main(im) | |
new_im.save('unknown2.jpg', 'JPEG') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment