I want to rotate the gray โtestโ image and paste it into the blue background image. Now I can just remove the black color after rotating my gray โtestโ image, but now it is white. How can I use Python to change the โwhiteโ color section to blue?
Here is my code, can someone help me? I would appreciate.
dst_im = Image.new("RGBA", (196,283), "blue" ) im = src_im.convert('RGBA') rot = im.rotate( angle, expand=1 ).resize(size) f = Image.new( 'RGBA', rot.size, (255,)*4 ) im2 = Image.composite( rot, f, rot ) im2.convert(src_im.mode) im2_width, im2_height = im2.size cut_box = (0, 0, im2_width, im2_height ) paste_box = ( left, top, im2_width+left, im2_height+top ) region = im2.crop( cut_box ) dst_im.paste( region, paste_box ) dst_im.save("test.gif")

Apple wang
source share