添加附件
This commit is contained in:
parent
260928ec35
commit
e4795f0c89
BIN
misc/easy_qrcode/1.jpg
Normal file
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
BIN
misc/easy_qrcode/2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
@ -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
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
BIN
misc/easy_qrcode/4.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
Loading…
x
Reference in New Issue
Block a user