鱼C论坛

 找回密码
 立即注册
查看: 1053|回复: 3

[已解决]GIF文件图像提取

[复制链接]
发表于 2020-5-22 20:28:33 | 显示全部楼层 |阅读模式
10鱼币
我没有学过PIL所以求解共有4道
最佳答案
2020-5-22 20:28:34
  1. from PIL import Image
  2. import os

  3. gif_photo = Image.open('篮球运动.gif')
  4. os.mkdir('篮球运动img')
  5. os.chdir('篮球运动img')
  6. try:
  7.     gif_photo.save(f'篮球运动{gif_photo.tell()}.png')
  8.     while True:
  9.         gif_photo.seek(gif_photo.tell()+1)
  10.         gif_photo.save(f'篮球运动{gif_photo.tell()}.png')
  11. except:
  12.     print('全部提取完成~')
复制代码

其他的你自己改改文件名即可~
1.png
明星漫画.gif
篮球运动.gif
猫咪.gif

最佳答案

查看完整内容

其他的你自己改改文件名即可~
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2020-5-22 20:28:34 | 显示全部楼层    本楼为最佳答案   
  1. from PIL import Image
  2. import os

  3. gif_photo = Image.open('篮球运动.gif')
  4. os.mkdir('篮球运动img')
  5. os.chdir('篮球运动img')
  6. try:
  7.     gif_photo.save(f'篮球运动{gif_photo.tell()}.png')
  8.     while True:
  9.         gif_photo.seek(gif_photo.tell()+1)
  10.         gif_photo.save(f'篮球运动{gif_photo.tell()}.png')
  11. except:
  12.     print('全部提取完成~')
复制代码

其他的你自己改改文件名即可~
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2020-5-22 23:45:12 | 显示全部楼层
官网手册都有的:https://pillow.readthedocs.io/en/stable/handbook/tutorial.html#

  1. from PIL import Image
  2. from PIL import ImageSequence


  3. with Image.open("test.gif") as im:
  4.     for n, frame in enumerate(ImageSequence.Iterator(im)):
  5.         frame.save(r'gif_%d.png' % n)
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2020-5-23 09:21:47 | 显示全部楼层
导入PS一张张拖出来
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-25 23:50

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表