0

Goal:

In Python,(Using libraries Pillow and Numpy) I need to paste one picture, into another picture - to get a combined picture that, used pic1 as a center, and pic2 as background.

This is pic1 and pic2:

enter image description hereenter image description here

enter image description here

What I have tried:

from PIL import Image

pice_img = Image.open(f'{pices_path}')
tiles_img = Image.open(f'{tiles_path}')
final_img = tiles_img.copy() 
final_img.paste(pice_img, (0, 0))
final_img.save(f'{final_path})

np.asarray(pice_img).shape # (240, 240, 2)
np.asarray(tiles_img).shape # (240, 240, 4)

When I try to save final_img. I got this as a result:

enter image description here

Thanks!

William Martens
  • 753
  • 1
  • 8
  • 27

1 Answers1

1

Solution

tiles_img.paste(pice_img, (0, 0), pice_img)