fix: 修复登录二维码扫描不上的bug

This commit is contained in:
Relakkes
2023-06-13 14:09:50 +08:00
parent e82dcae02f
commit c0a783fa35
2 changed files with 11 additions and 7 deletions
+10 -6
View File
@@ -1,12 +1,9 @@
import json
import time
import base64
import random
import hashlib
import base64
from io import BytesIO
from typing import Optional, Dict, List, Tuple
from PIL import Image
from PIL import Image, ImageDraw
from playwright.async_api import Cookie
from playwright.async_api import Page
@@ -30,7 +27,14 @@ def show_qrcode(qr_code: str):
qr_code = qr_code.split(",")[1]
qr_code = base64.b64decode(qr_code)
image = Image.open(BytesIO(qr_code))
image.show()
# Add a square border around the QR code and display it within the border to improve scanning accuracy.
width, height = image.size
new_image = Image.new('RGB', (width + 20, height + 20), color=(255, 255, 255))
new_image.paste(image, (10, 10))
draw = ImageDraw.Draw(new_image)
draw.rectangle((0, 0, width + 19, height + 19), outline=(0, 0, 0), width=1)
new_image.show()
def get_user_agent() -> str: