【发布时间】:2020-12-15 15:14:02
【问题描述】:
我正在尝试使用带有自定义标签的 PIL 保存 TIFF 图像。
import numpy as np
import PIL
numrows=10
numcols=10
data = np.random.randint(0, 255, (numrows,numcols)).astype(np.uint8)
rawtiff=PIL.Image.fromarray(data)
custtifftags={'Photometric':1, 'Compression':1, 'BitsPerSample':32,\
'SamplePerPixel':1, 'SampleFormat':3,'ImageLength':10,\
'ImageWidth':10, 'PlanarConfiguration':1, 'ResolutionUnit':2}
rawtiff.save('test.tiff', tiffinfo=custtifftags)
我收到以下错误:
TypeError: '<' not supported between instances of 'str' and 'int'
是什么导致了这个错误?如何在设置我自己的标签时使用 PIL 保存图像?
【问题讨论】:
标签: python python-3.x image python-imaging-library tiff