As I am trying to make a game with some pixel style in it, just to be in the 80ies game mood, here some simple code is to create a pixelate effect on an image. Let’s say we got this:
Let’s pixelite it
Code to pixelize an image with PIL (pillow)
To install PIL use the fork pillow:
pip install pillow
#!/usr/local/bin/python3
from PIL import Image
import os
# Open The Image to PIXELIZE
img = Image.open("image2.jpg")
# The smallest is the resize, the biggest are the PIXELS
# imgSmall = img.resize((128, 128), resample=Image.BILINEAR)
# If you do want ANTIALISING uncomment the line above and comment the one below
imgSmall = img.resize((256, 256))
# Scale back up using NEAREST to original size
result = imgSmall.resize(img.size,Image.NEAREST)
# Save
result.save('result.png')
os.startfile('result.png')
# os.startfile('image.png')

