Skip to content

Commit ac573c8

Browse files
authored
Create wx_bdd.py
1 parent 97fdbdc commit ac573c8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

moumoubaimifan/bdd/wx_bdd.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from PIL import Image
2+
import os
3+
4+
path = 'D:/bdd/'
5+
tx_img = Image.open(os.path.join(path,'tx.jpg'))
6+
bdd_img = Image.open(os.path.join(path,'bdd.png'))
7+
8+
tx_rgba = tx_img.convert('RGBA')
9+
bdd_rgba = bdd_img.convert('RGBA')
10+
11+
tx_x, tx_y = tx_rgba.size
12+
bdd_x, bdd_y = bdd_rgba.size
13+
14+
scale = 5
15+
img_scale = max(tx_x / (scale * bdd_x), tx_y / (scale * bdd_y))
16+
new_size = (int(bdd_x * img_scale), int(bdd_y * img_scale))
17+
bdd = bdd_rgba.resize(new_size, resample=Image.ANTIALIAS)
18+
bdd.show()
19+
20+
bdd_x, bdd_y = bdd.size
21+
tx_rgba.paste(bdd, (tx_x - bdd_x, tx_y - bdd_y), bdd)
22+
tx_rgba.show()
23+
24+
tx_rgba.save(os.path.join(path,'tx_bdd.png'))

0 commit comments

Comments
 (0)