I am looking for a smart way to create a blurry gif from a gif.
Currently I have a script to do the same for jpeg / png :
blurry_image = Image.open(file).filter(ImageFilter.BoxBlur(50))
blurry_output = io.BytesIO()
blurry_image.save(blurry_output, format=image_format)
but this script does not work for gif, is there an easy way to do that in python ?
Thanks
Thanks to @Marcel, I succeed to do the work by looping over frames
im = Image.open(file)
frames = [np.asarray(im_frame.convert('RGB').filter(ImageFilter.BoxBlur(50)))
for im_frame in ImageSequence.Iterator(im)]
blurry_images = [Image.fromarray(a_frame) for a_frame in np.stack(frames)]
blurry_images[0].save(blurry_output, save_all=True, append_images=blurry_images[1:], format='gif', loop=0)
I don't know if there is already a library to do it directly, but here it is working Basically, it saves all the frame in PNG format image (with blurry option), and rebuild the gif from all these frames saved