我正在尋找一種將新調色板應用於現有8位.png圖像的快速方法。我怎樣才能做到這一點?當我保存圖像時,.png是否被重新編碼? (自己的答案:它似乎很)使用python更改8位.png圖像的調色板PIL
我都試過(編輯):
import Image, ImagePalette
output = StringIO.StringIO()
palette = (.....) #long palette of 768 items
im = Image.open('test_palette.png') #8 bit image
im.putpalette(palette)
im.save(output, format='PNG')
隨着我testimage保存功能大約需要65米利斯。我的想法:沒有解碼和編碼,它可以快很多?
實例:http://stackoverflow.com/questions/236692/how-do-i-convert-any-image-to-a-4-color-paletted-image-using -python-imaging-l – 2009-07-21 11:58:42