首页 > 解决方案 > 枕头:将 GIF 转换为动画 webp 会产生一些噪音

问题描述

我做了一个简单的转换方法如下:

from PIL import Image

def convert(src, dst):
    with Image.open(src) as img:
        print(f'file opened = {src}')
        if hasattr(img, 'is_animated') and img.is_animated:
            print(f'frames = {img.n_frames}')
            img.save(dst,
                quality=90,
                save_all=True)
        else:
            print('not animated')
            img.save(dst, quality=90)

if __name__ == '__main__':
    convert('src.gif','dst.webp')

我将一些.gif图像转换为动画 webp,图像上有噪音。


结果:

结果


我错过了什么?

我正在使用 Python 3.9.7 Pillow 8.3.2。


来源1:

来源1

来源2:

来源2

标签: pythonpython-imaging-librarywebp

解决方案


推荐阅读