I'm making a chess bot which will run in a chat program reacting and moving pieces according to commands from users. As such, I am trying to make it paste png images of chess pieces on top of a png background image of a chessboard by using the python package pillow.
In any other software, the chess pieces have transparent backgrounds and whatever is behind them show through but when I paste it on top of the chessboard using pillow the chess-piece gets a grey background which does not match the tile on the chessboard.
Is there a way in which I can paste the chess-piece image on top of my chessboard background without the added grey background colour of the chess-piece? Or is there an alternative way of doing this in python which will give the desired result?
I'm not done with the bot and the game logic but as an example, I have included some code illustrating how I've pasted one image on top of the other one below:
from PIL import Image
board = Image.open('assets/chessboard.png')
w_pawn = Image.open('assets/w_pawn_png_shadow_128px.png')
a_eight = (102, 30, 210, 158) # Left, top, right and bottom coordinates of where the piece is pasted onto the board
battle_board = board.copy()
battle_board.paste(w_pawn, a_eight)
battle_board.show()
Just to quickly show what the output looks like I've included a screenshot of what a pawn looks like when it's pasted onto the board: