-
I've been searching for this since months now... How can I pixelate gif using python? How is this possible with python? Please someone help me. |
Beta Was this translation helpful? Give feedback.
Answered by
radarhere
Apr 14, 2022
Replies: 1 comment 5 replies
-
Running this code over your original image, from PIL import Image, ImageSequence
def pixelate(frame):
if frame.mode == "P":
frame = frame.convert("RGB")
original_size = frame.size
# To create the pixelation effect,
# shrink the image by a factor of 5
frame = frame.reduce(5)
# and then resize it back to normal size
return frame.resize(original_size, Image.Resampling.NEAREST)
# Open the image
with Image.open("in.gif") as im:
# Run the "pixelate" function over every frame
frames = ImageSequence.all_frames(im, pixelate)
# Save it to file
frames[0].save("out.gif", save_all=True, append_images=frames[1:]) |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
Lypheal
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Running this code over your original image,
gives