我正在从头开始创建黑白 TIF 图像,并使用 Python 的图像库在其上绘制文本。在 Windows 7 上使用 Python 2.7、PIL 1.1.7。
要创建每个图像,我使用此代码
def newBinaryImage(w,h):
return Image.new("1",(w,h),1)
当我在任何 Windows 图像查看器中打开它们时,它们看起来都很好。在我将它们上传到数据库中,然后使用定制的 GUI 查看它们后,它们在 GUI 查看器中看起来很好。但是,当我尝试从 GUI 打印它们时,它们会反转并打印为黑色背景上的白色文本。(在加载前打印时不会发生这种情况。)
在联系了创建自定义软件的供应商后,他们告诉我们他们认为问题可能出在 photometricinterpretation 标签上,可以通过使用 Group4 压缩来解决。有没有办法在 PIL 中做到这一点,或者在创建图像时有什么可以/应该改变的吗?
这是我的一张图片上的 Image.DEBUG:
>>>Image.open("1010.tif").show()
tag: ImageWidth (256) - type: short (3) - value: (1200,)
tag: ImageLength (257) - type: short (3) - value: (1600,)
tag: Compression (259) - type: short (3) - value: (1,)
tag: PhotometricInterpretation (262) type: short (3) - value: (1,)
tag: StripOffsets (273) - type: long (4) - value: (98,)
tag: RowsPerStrip (278) - type: short (3) - value: (1600,)
tag: StripByteCounts (279) - type: long (4) - value: (240000,)
*** Summary ***
- compression: raw
- photometric_interpretation: 1
- planar_configuration: 1
- fill_order: 1
- size: (1200,1600)
format key: ('II', 1, 1, 1, (1,), ())
- raw mode: 1
- pil mode: 1