一般从网页截图下的全屏图片,在电脑打开会进行缩放,因为大部分电脑在显示那里设置都是125%的缩放
则,电脑打开的截图是网页截屏的1.25倍。
解决方法:
1、更改电脑的显示设置,将缩放与布局设置成100%
2、在对图片进行处理的时候,将相应图片的位置参数*1.25,
# 验证码图片位置
code_img_w = code_tag.location
x = int(code_img_w['x']) * 1.25
y = int(code_img_w['y']) * 1.25
height = int(code_img_site['height']) * 1.25
width = int(code_img_site['width']) * 1.25
# 因为我们桌面是125%显示
img_tu = (x, y, x + width, y + height)
img = Image.open('./web.png')
code_img = img.crop(img_tu)
code_img.save('code_img.png')