Is there anyway paste a RGBA image on a color blank but still keep alpha channel as it before?

Viewed 17

This is my code:

new_img = Image.new('RGBA', (new_size, new_size))
new_img.paste(img, (delta_w,delta_h))
new_img.split()[-1].save('5.png')

new_img = Image.new('RGB', (new_size, new_size), color)
new_img.paste(img, (delta_w,delta_h), mask=img)
new_img.save('4.png')

please tell me is there another way shorter and faster

0 Answers
Related