MISC二進制轉二維碼
from PIL import Image
from zxing import BarCodeReader
reader = BarCodeReader()
MAX = 70
pic = Image.new("RGB", (MAX, MAX))
binary_nums = """""".replace('\n', '')
i = 0
for y in range(0, MAX):
? ? for x in range(0, MAX):
? ? ? ? if binary_nums[i] == '1':
? ? ? ? ? ? pic.putpixel([x, y], (0, 0, 0))
? ? ? ? else:
? ? ? ? ? ? pic.putpixel([x, y], (255, 255, 255))
? ? ? ? i = i + 1
# pic.show()
pic.save("flag.png")
barcode = reader.decode('flag.png')
print(barcode.parsed)
標簽: