我使用以下代碼來疊加的圖像上使用PIL當我在其上疊加另一圖像
path = "/home/blah.png"
background = Image.open(path)
product = Image.open("/home/51tmBaivYhL._SL75_.jpg")
background.paste(product, (20,40))
background.save("/home/newImage.jpg")
這些是我使用作爲背景http://i.imgur.com/bwPFT.png,產品圖像的另一圖像PIL污跡圖像http://i.imgur.com/Ig6qV.jpg這就是結果顯示爲http://i.imgur.com/JfGoS.jpg
希望我能得到任何幫助。
謝謝。
編輯:另外,當我嘗試background.paste(product, (20,40), product)
,我得到的錯誤「ValueError異常:糟糕的透明度面具」
您提供了相同的產品和結果鏈接,我認爲結果丟失了。如果沒有它,很難知道你的投訴是什麼。 –
此外,「產品」圖片太小以至於無法使用。 – agf
對不起,我做了更改。 @agf,任何圖像確實會導致背景在右上角出現「污跡」問題,並且出於某種原因出現灰色背景。 – iman453