0

Code:

from PIL import Image, ImageDraw
import requests

img = Image.new('RGBA', (500, 500), 'black')
canvas = ImageDraw.Draw(img)

logo = Image.open(requests.get('https://api-assets.clashofclans.com/badges/70/-1w_sJci3z0Z8XYk-PT9vDhgJzmgzrhdxPbKAUD298s.png', stream=True).raw)

img.paste(logo.convert('RGBA'))

img.show()

the result look like this




how to make the pasted image integration completely?

I want to make the pasted image integration completely

2 Answers2

0

Just change 'black' to (0, 0, 0, 0)

from PIL import Image, ImageDraw
import requests

img = Image.new('RGBA', (500, 500), (0, 0, 0, 0))
canvas = ImageDraw.Draw(img)

logo = Image.open(requests.get('https://api-assets.clashofclans.com/badges/70/-1w_sJci3z0Z8XYk-PT9vDhgJzmgzrhdxPbKAUD298s.png', stream=True).raw)

img.paste(logo.convert('RGBA'))

img.show()
koegl
  • 505
  • 2
  • 13
-1
from PIL import Image, ImageDraw
import requests

img = Image.new('RGBA', (500, 500), 'black')
canvas = ImageDraw.Draw(img)

logo = Image.open(requests.get('https://api-assets.clashofclans.com/badges/70/-1w_sJci3z0Z8XYk-PT9vDhgJzmgzrhdxPbKAUD298s.png', stream=True).raw)

img.paste(logo.convert('RGBA'), (0, 0), logo.convert('RGBA')) # (0, 0) is position

img.show()
  • Users find it difficult to understand code only answers with no explanation. Please consider adding some description explaining what is does and how it solves the problem or add comments in the source code at appropriate places. – Azhar Khan Jan 02 '23 at 13:36