Skip to content

Instantly share code, notes, and snippets.

@dogterbox
Forked from mpuig/gist:1582085
Created January 6, 2023 13:49
Show Gist options
  • Save dogterbox/f4f6e75ab0b954be9ed75c7178135a88 to your computer and use it in GitHub Desktop.
Save dogterbox/f4f6e75ab0b954be9ed75c7178135a88 to your computer and use it in GitHub Desktop.
How to reduce color palette with PIL
import Image
im = Image.open('image.jpg')
# using Image.ADAPTIVE to avoid dithering
out = im.convert('P', palette=Image.ADAPTIVE, colors=5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment