添加附件

This commit is contained in:
sangge 2023-09-04 10:29:28 +08:00
parent 260928ec35
commit e4795f0c89
5 changed files with 32 additions and 0 deletions

BIN
misc/easy_qrcode/1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
misc/easy_qrcode/2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -1,4 +1,5 @@
import qrcode
from PIL import Image
def generate_qr(data, file_name="qr.png"):
"""
@ -23,3 +24,34 @@ with open("flag.txt","r") as f:
text = f.read()
generate_qr(text,"qr.png")
def split_image_into_quarters(image_path):
# 打开图像文件
image = Image.open(image_path)
# 获取图像的宽度和高度
width, height = image.size
# 计算每个区块的宽度和高度
quarter_width = width // 2
quarter_height = height // 2
# 切割图像为四块
top_left = image.crop((0, 0, quarter_width, quarter_height))
top_right = image.crop((quarter_width, 0, width, quarter_height))
bottom_left = image.crop((0, quarter_height, quarter_width, height))
bottom_right = image.crop((quarter_width, quarter_height, width, height))
return top_left, top_right, bottom_left, bottom_right
# 图像文件路径
image_path = "qr.png"
# 将图像切割成四块
top_left, top_right, bottom_left, bottom_right = split_image_into_quarters(image_path)
# 保存切割后的图像
top_left.save("3.jpg")
top_right.save("2.jpg")
bottom_left.save("4.jpg")
bottom_right.save("1.jpg")

BIN
misc/easy_qrcode/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
misc/easy_qrcode/4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB