Created
January 21, 2021 14:54
-
-
Save Refffy/c90a38b70348be183d6974dba20814c8 to your computer and use it in GitHub Desktop.
This file contains 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 | |
from sys import argv | |
def pixelate(inpt, outpt, colors, k): | |
img = Image.open(inpt).convert('P', palette=Image.ADAPTIVE, colors=colors) | |
w, h = img.size | |
img = img.resize((285, 385)).resize((w, h), Image.NEAREST) | |
img.quantize(colors=colors, kmeans=k) | |
img.save(outpt) | |
if __name__ == '__main__': | |
pixelate(argv[1], argv[2], int(argv[3]), int(argv[4])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment