0
我從頭開始創建黑白TIF圖像,並使用Python的圖像庫在其上繪製文本。在Windows 7上使用Python 2.7,PIL 1.1.7PIL中的倒立tiff圖像和光度解釋標籤?
要創建每個圖像,我用這個代碼
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
打印機傳統上忽略1位圖像上的調色板,並簡單地假定0 =白色和1 =黑色。你需要改變你的圖像來匹配,但我不認爲PIL可以讓你在模式1的圖像上改變調色板。 – 2013-05-01 19:56:57