2017-05-09 22 views
1

我粘貼另一個圖像上的圖像,並期待在this問題後,我看到的是,爲了粘貼透明圖像,你需要做的蟒蛇PIL - 檢查,如果圖像是透明的

background = Image.open("test1.png") 
foreground = Image.open("test2.png") 

background.paste(foreground, (0, 0), foreground) 

正常圖像,你應該做的

background = Image.open("test1.png") 
foreground = Image.open("test2.png") 

background.paste(foreground, (0, 0)) // difference here 

我的問題是,我怎麼能檢查如果圖像是透明的,所以我可以決定如何使用paste方法(帶或不帶最後一個參數)。

回答