PyLibTIff 是 Python 用来处理 TIFF 图像的开发包,示例代码:
from libtiff import TIFF to open a tiff file for reading: tif = TIFF.open(‘filename.tif’, mode=’r’) to read an image in the currect TIFF directory and return it as numpy array: image = tif.read_image() to read all images in a TIFF file: for image in tif.iter_images(): # do stuff with image to open a tiff file for writing: tif = TIFF.open(‘filename.tif’, mode=’w’) to write a image to tiff file tif.write_image(image)
from libtiff import TIFF
tif = TIFF.open(‘filename.tif’, mode=’r’)
array: image = tif.read_image()
for image in tif.iter_images(): # do stuff with image
tif = TIFF.open(‘filename.tif’, mode=’w’)
tif.write_image(image)