-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAlipayVR.py
39 lines (28 loc) · 978 Bytes
/
AlipayVR.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#支付宝VR红包图片生成 成功率60%左右
from PIL import Image, ImageFilter
im = Image.open("IMG_2704.PNG")
box = im.copy()
box = (200, 630, 550, 980) #适配iPhone6屏幕.其他手机屏幕修改参数
region = im.crop(box)
boder = 6 #修改位移数值
box1 = im.copy()
box1= (200, 630+boder, 550, 980+boder)
region1 = im.crop(box1)
res = Image.blend(region,region1,0.5)
# 高斯模糊
class MyGaussianBlur(ImageFilter.Filter):
name = "GaussianBlur"
def __init__(self, radius=2, bounds=None):
self.radius = radius
self.bounds = bounds
def filter(self, image):
if self.bounds:
clips = image.crop(self.bounds).gaussian_blur(self.radius)
image.paste(clips, self.bounds)
return image
else:
return image.gaussian_blur(self.radius)
bounds = (0, 0, 340, 340)
image = res
image = image.filter(MyGaussianBlur(radius=2.5, bounds=bounds)) #radius=模糊系数
image.show()