原文:http://blog.csdn.net/u011500307/article/details/28163389

import os

from PIL import Imagedef analyseImage(path):im = Image.open(path)results = {'size': im.size,'mode': 'full',}try:while True:if im.tile:tile = im.tile[0]update_region = tile[1]update_region_dimensions = update_region[2:]if update_region_dimensions != im.size:results['mode'] = 'partial'
                    break
            im.seek(im.tell() + 1)except EOFError:pass
    return resultsdef processImage(path):mode = analyseImage(path)['mode']im = Image.open(path)i = 0
    p = im.getpalette()last_frame = im.convert('RGBA')try:while 1:print("saving %s (%s) frame %d, %s %s" % (path, mode, i, im.size, im.tile))'''''
            If the GIF uses local colour tables, each frame will have its own palette.
            If not, we need to apply the global palette to the new frame.
            '''
            if not im.getpalette():im.putpalette(p)new_frame = Image.new('RGBA', im.size)'''''
            Is this file a "partial"-mode GIF where frames update a region of a different size to the entire image?
            If so, we need to construct the new frame by pasting it on top of the preceding frames.
            '''
            if mode == 'partial':new_frame.paste(last_frame)new_frame.paste(im, (0, 0), im.convert('RGBA'))new_frame.save('%s-%d.png' % (''.join(os.path.basename(path).split('.')[:-1]), i), 'PNG')i += 1
            last_frame = new_frameim.seek(im.tell() + 1)except EOFError:pass
if __name__ == "__main__":processImage('j8ks.gif')

python提取图像的每一帧相关推荐

  1. OpenCV python 提取图像内的三色

    OpenCV python 提取图像内的三色 原图 [opencv.jpg] import cv2 import numpy as npdef main():# 1.导入图片img_src = cv2 ...

  2. 利用python提取图像轮廓

    from PIL import Imagefrom pylab import * # 读取图像到数组中 # convert('L')表示将RGB转换为L模式,表示像素点在[0,255]之间im = a ...

  3. 模式识别作业,基于python提取图像纹理特征

    其中的直方图的绘画部分要注意,只写了部分的直方图代码###直接调用skimag库中的函数BLP提取纹理 from skimage import dataimport matplotlib.pyplot ...

  4. python提取列表中文本_python提取图像的名字*.jpg到txt文本的方法

    如下所示: # -*- coding:utf-8 -*- import sys sys.path.append('E:\\Anaconda\\libs') import os #os:操作系统相关的信 ...

  5. python获取图片名称_python提取图像的名字*.jpg到txt文本的方法

    如下所示: # -*- coding:utf-8 -*- import sys sys.path.append('E:\\Anaconda\\libs') import os #os:操作系统相关的信 ...

  6. python opencv二值化图像_python opencv,读取彩色图像,提取三通道,图像二值化,提取图像的边缘...

    python opencv,读取彩色图像,提取三通道,图像二值化,提取图像的边缘 python opencv 1,读取图像 2,图像变矩阵 3,图像转灰度图像 4,彩色图像是3D数组 5,灰度图像是2 ...

  7. 使用OpenCV和Python从图像中提取形状

    Welcome to the first post in this series of blogs on extracting features from images using OpenCV an ...

  8. python读取图像并相加_python给图像加上mask,并提取mask区域实例

    python对图像提取mask部分: 代码: #coding:utf-8 import os import cv2 import numpy as np def add_mask2image_bina ...

  9. halcon边缘提取颜色相近_初学者福利!三种用Python从图像数据中提取特征的技术...

    全文共4073字,预计学习时长8分钟 你之前是否使用过图像数据?也许你想建立自己的物体检测模型,或者仅仅是想统计走进某栋建筑物的人数,使用计算机视觉技术处理图像拥有无穷无尽的可能性. 但数据科学家最近 ...

最新文章

  1. python垂直输出hello_python - 我如何获得直方图以垂直输出数据? - SO中文参考 - www.soinside.com...
  2. linux sftp 可以看到中文目录 复制后中文消失_Linux部署最新版Aria2+AriaNG
  3. html圆形修饰,HTML修饰效果集锦(演示与代码)
  4. InstallShield 2011中数字签名失败的问题
  5. SAP 库存相关表格
  6. 使用 SAP UI5 CLI 命令行工具构建和运行 SAP UI5 应用
  7. 带你读AI论文丨LaneNet基于实体分割的端到端车道线检测
  8. 【Flink】使用Flink实现索引数据到Elasticsearch
  9. linux sys伪用户作用,linux用户管理详解
  10. Spring Boot(三):Spring Boot Jpa的介绍及Jpa的使用
  11. Ubuntu18.04搭建本地RTMP服务器librtmp+nginx,推送flv文件播放
  12. ArcGIS学习总结(二)——空间数据处理
  13. 一个https神奇的故事
  14. TypeError:Cannot read property 'bind' of underfined(React)
  15. 秋草独寻人去后——986山野穿越点滴(七)
  16. 【Python常微分方程】
  17. 输入手机号格式344展示形式(只允许数字)
  18. 23道Python基础练习题附答案
  19. SCNN-用于时序动作定位的多阶段3D卷积网络
  20. Xcode 9使用时那些坑

热门文章

  1. mysql 游标循环_mysql for循环遍历 游标用处
  2. leetcode 50 口诀
  3. java byter是字节吗_GitHub - XXQAQ/Byter: 字节对象转换框架,一个基于字节的 Gson/FastJson...
  4. 给数组倒序_22个超详细的 JS 数组方法
  5. mysql参数文件选项组_选项文件(Option Files)/配置文件(Configuration Files)的使用
  6. 怎么打开外部文件_保存的DWG文件再次用CAD打开时提示文件损坏了怎么办?【AutoCAD教程】...
  7. 戴尔服务器r210显示3,Dell服务器R210
  8. 小姐姐在硅谷生活了三年,实现了理想的生活模式
  9. 何为 Serverless 架构模式?这 5 大场景来告诉你!
  10. fpm制作mysql rpm包_fpm制做mysql-5.6.33 rpm包