文章詳情頁(yè)
Python如何使用PIL Image制作GIF圖片
瀏覽:3日期:2022-07-25 11:59:30
1.基本構(gòu)架:
mport PIL.Image 相關(guān)模塊 img=Image.open(img_name) 打開圖片 img.save(save_name, save_all=True, append_images=imgs, duration=t) 保存圖片2.代碼
import PIL.Image as Imagedef get_gif(pic_dir,n,t=0.1): imgs = [] for i in range(n): pic_name = ’{}/{}.png’.format(pic_dir,i) temp = Image.open(pic_name) imgs.append(temp) save_name = ’{}.gif’.format(pic_dir) imgs[0].save(save_name, save_all=True, append_images=imgs, duration=t) return save_nameif __name__ == ’__main__’: pic_dir = ’dmp’ save_name = get_gif(pic_dir,40,0.25) print(’制作完成。所屬文件:{}’.format(save_name))
3、效果圖
4、GIF圖
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. SXNA RSS Blog 聚合器程序2. PHP設(shè)計(jì)模式中工廠模式深入詳解3. ASP常用日期格式化函數(shù) FormatDate()4. JSP的Cookie在登錄中的使用5. ASP 信息提示函數(shù)并作返回或者轉(zhuǎn)向6. XML 增、刪、改和查示例7. 使用Spry輕松將XML數(shù)據(jù)顯示到HTML頁(yè)的方法8. ASP動(dòng)態(tài)網(wǎng)頁(yè)制作技術(shù)經(jīng)驗(yàn)分享9. webpack高級(jí)配置與優(yōu)化詳解10. jsp實(shí)現(xiàn)登錄驗(yàn)證的過濾器
排行榜
