chunk模块用于读取TIFF格式的文件,打开应该使用二进制模式

TIFF 标签图像文件格式

import chunk

import chunk f=open('E:\\test.tiff','rb') print(type(f)) html=chunk.Chunk(f) print(html.getname()) print(html.getsize())

help('chunk')

Help on module chunk:

NAME

chunk - Simple class to read IFF chunks.

DESCRIPTION

An IFF chunk (used in formats such as AIFF, TIFF, RMFF (RealMedia File

Format)) has the following structure:

+----------------+

| ID (4 bytes)   |

+----------------+

| size (4 bytes) |

+----------------+

| data           |

| ...            |

+----------------+

The ID is a 4-byte string which identifies the type of chunk.

The size field (a 32-bit value, encoded using big-endian byte order)

gives the size of the whole chunk, including the 8-byte header.

Usually an IFF-type file consists of one or more chunks.  The proposed

usage of the Chunk class defined here is to instantiate an instance at

the start of each chunk and read from the instance until it reaches

the end, after which a new instance can be instantiated.  At the end

of the file, creating a new instance will fail with an EOFError

exception.

Usage:

while True:

try:

chunk = Chunk(file)

except EOFError:

break

chunktype = chunk.getname()

while True:

data = chunk.read(nbytes)

if not data:

pass

# do something with data

The interface is file-like.  The implemented methods are:

read, close, seek, tell, isatty.

Extra methods are: skip() (called by close, skips to the end of the chunk),

getname() (returns the name (ID) of the chunk)

The __init__ method has one required argument, a file-like object

(including a chunk instance), and one optional argument, a flag which

specifies whether or not chunks are aligned on 2-byte boundaries.  The

default is 1, i.e. aligned.

CLASSES

builtins.object

Chunk

class Chunk(builtins.object)

|  Methods defined here:

|

|  __init__(self, file, align=True, bigendian=True, inclheader=False)

|      Initialize self.  See help(type(self)) for accurate signature.

|

|  close(self)

|

|  getname(self)

|      Return the name (ID) of the current chunk.

|

|  getsize(self)

|      Return the size of the current chunk.

|

|  isatty(self)

|

|  read(self, size=-1)

|      Read at most size bytes from the chunk.

|      If size is omitted or negative, read until the end

|      of the chunk.

|

|  seek(self, pos, whence=0)

|      Seek to specified position into the chunk.

|      Default position is 0 (start of chunk).

|      If the file is not seekable, this will result in an error.

|

|  skip(self)

|      Skip the rest of the chunk.

|      If you are not interested in the contents of the chunk,

|      this method should be called so that the file points to

|      the start of the next chunk.

|

|  tell(self)

|

|  ----------------------------------------------------------------------

|  Data descriptors defined here:

|

|  __dict__

|      dictionary for instance variables (if defined)

|

|  __weakref__

|      list of weak references to the object (if defined)

FILE

c:\python3.5\lib\chunk.py

摘自:
https://www.cnblogs.com/dengyg200891/p/4947685.html

转载于:https://www.cnblogs.com/baxianhua/p/10169665.html

python chunk模块相关推荐

  1. Python Re 模块超全解读!详细

    内行必看!Python Re 模块超全解读! 2019.08.08 18:59:45字数 953阅读 121 re模块下的函数 compile(pattern):创建模式对象 > import ...

  2. python argparse模块_Python argparse模块应用实例解析

    这篇文章主要介绍了Python argparse模块应用实例解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 简介 argparse是python ...

  3. 关于使用python logging模块的几点总结

    关于使用python logging模块的几点总结 使用python的标准日志模块logging可以非常方便地记录日志.Python日志系统非常丰富.添加结构化或非结构化日志输出到python代码,写 ...

  4. python高级-模块(14)

    一.python中的模块 有过C语言编程经验的朋友都知道在C语言中如果要引用sqrt函数,必须用语句#include <math.h>引入math.h这个头文件,否则是无法正常进行调用的. ...

  5. 转载: Python os 模块的功能以及子函数介绍

    原文链接: python之os模块 - 程序生(Codey) - 博客园 https://www.cnblogs.com/cxscode/p/8085326.html 一.Python OS模块介绍 ...

  6. 简单介绍python process模块

    在python中大部分情况需要使用多进程,python提供了multiprocessing模块.multiprocessing模块的功能众多:支持子进程.通信和共享数据.执行不同形式的同步,提供了Pr ...

  7. python io模块_python中的StringIO模块

    原博文 2015-10-23 15:21 − # python中的StringIO模块 标签:python StringIO --- > 此模块主要用于在内存缓冲区中读写数据.模块是用类编写的, ...

  8. python正则表达式需要模块_使用Python正则表达式模块,让操作更加简单

    处理文本数据的一个主要任务就是创建许多以文本为基础的特性. 人们可能想要在文本中找出特定格式的内容,比如找出存在于文本中的电子邮件,或者大型文本中的电话号码. 虽然想要实现上述功能听起来很繁琐,但是如 ...

  9. python导入模块有同名_Python:导入与函数同名的模块

    背景:第一次在SE上提问.我在 Python方面还很陌生,而且在编程方面也不是很有经验.我已经四处寻找,但我没有找到这个问题的答案,我非常感谢你的帮助. 我的问题是:如何导入与函数同名的模块? 具体来 ...

  10. python第三方模块—psutil模块

    系统基础信息采集模块作为监控模块的重要组成部分,能够帮助运维人员了解当前系统的健康程度,同时也是衡量业务的服务质量的依据,比如系统资源吃紧,会直接影响业务的服务质量及用户体验,另外获取设备的流量信息, ...

最新文章

  1. Python 图像处理 | 图像平滑之均值滤波、方框滤波、高斯滤波及中值滤波
  2. CNN卷积层图像和矩阵转换函数
  3. jmeter 最大时间长_长连接和短连接区别和优缺点
  4. kail中tools的安装和第一个php学习笔记
  5. Chrome 爬虫插件 Web Scraper
  6. 刚刚,百度宣布王海峰升任 CTO
  7. 在线图片水平/垂直均等切割工具
  8. 喜马拉雅下载文件名批量修改
  9. 经典怀旧:VirtualBox安装Win95 - 详细图片展示
  10. 【智能制造】海阔凭鱼跃:记一场工业场景下的AI技术实践
  11. 前端开发工程师,CSS盒子模型居中方法
  12. python修改sheet名称_python excel练习:新建sheet、修改名称、设定颜色、打印sheet名称,复制,保存...
  13. Ant实现自动打包部署
  14. Android 调用手机相册、摄像头拍照及剪裁照片
  15. 黑苹果MAC好处与坏处
  16. 比较好的网页视频播放器总结
  17. 经典SQL--求一年有多少天
  18. Matlab:查找符合条件的数组元素
  19. myos1 大学生利用C++构建一个完整的操作系统打印helloworld
  20. 详解淘客失败原因 用淘宝客还能赚到钱吗

热门文章

  1. 数字签名、电子签名与电子合同
  2. K-Means聚类算法原理及实现
  3. java jcp_亚马逊加入Java社区流程(JCP)
  4. 优化 RTD 温度传感系统:接线配置
  5. JAVA 超详细 将文件夹目录打包为 ZIP 压缩包并下载
  6. excel删除无尽空白行_史上最简单的Excel工资条制作方法,实用收藏!
  7. C# 学习——LINQ 查询
  8. 华为电脑Linux进pe,华为 PE-TLOOM 开启USB调试模式
  9. 看小姐姐用动图展示 10 大 Git 命令
  10. sql 取最近一周的周几_我最近的几周摘要