使用PIL将png图片转换成gif图片

    xiaoxiao2022-06-27  147

    程序小记录

    from PIL import Image import os import glob

    “”“将png图片转化为gif图片”"" def convert(i_dir,o_dir): for img in os.listdir(i_dir):

    # base_name = os.path.basename(i_dir) # name = os.path.splitext(base_name)[0] # new_name = name + ".gif" # ol = os.path.join(o_dir, new_name) # Image.open(img).save(ol) im = Image.open(os.path.join(i_dir,img)) images = [] im.save(o_dir+img.split('.')[0]+'.gif', save_all=True, append_images=images, loop=1, duration=1, comment=b"aaabb")

    最新回复(0)