文章詳情頁
Python如何使用PIL Image制作GIF圖片
瀏覽:8日期: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. XML在語音合成中的應(yīng)用2. ASP將數(shù)字轉(zhuǎn)中文數(shù)字(大寫金額)的函數(shù)3. 不要在HTML中濫用div4. HTML5實(shí)戰(zhàn)與剖析之觸摸事件(touchstart、touchmove和touchend)5. HTTP協(xié)議常用的請(qǐng)求頭和響應(yīng)頭響應(yīng)詳解說明(學(xué)習(xí))6. XML入門的常見問題(三)7. jscript與vbscript 操作XML元素屬性的代碼8. 完美的ASP分頁腳本代碼9. .NET Core 分布式任務(wù)調(diào)度ScheduleMaster詳解10. XML 非法字符(轉(zhuǎn)義字符)
排行榜
