2015-11-02 69 views
1

我目前正在製作一個程序,它將信息呈現給緩衝區,並且我想將信息保存爲某種圖像文件到我的工作目錄。我見過一些使用PIL的例子,但是python 3.x不支持該庫。有更好的選擇嗎?在python 3.x中創建,修改和保存圖像

+1

試試PIL的克隆,[Pillow](https://pypi.python.org/pypi/Pillow)。它有一個3.X分支,最後我檢查了一下。 – Kevin

+0

是的,凱文是對的。我使用Pillow來處理3.x中的所有圖像處理需求。 – BlivetWidget

+0

奇怪,我通過pip安裝了枕頭,但是我無法將它導入python命令行。點子列表顯示Pillow已安裝。 – Maurdekye

回答

0

先卸載PIL比安裝Pillow

其一個PIL的克隆,其對Python的3.x的工作

from PIL import Image 
img = Image.open("test1.jpg") #jpg, png, etc. 
pix = img.load() 
print img.size #Get the width and height of the image for iterating over 
print pix[15,15] #Get the RGBA Value of the a pixel of an image 
pix[15, 15] = value # Set the RGBA Value of the image (tuple) 
img.save("out.jpg") # Saves the modified pixels to image 
+0

我從來沒有安裝過PIL,因爲我運行的是python 3,並沒有在pip中列出。 – Maurdekye

+0

編輯我的答案。請嘗試。 –

+0

我無法導入PIL。 – Maurdekye