Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def generate_image() -> None:
- #---------------Subfunc-----------------#
- def attention() -> None:
- print("Внимание! Изображение должно быть сторого разрешения 106х17 пикселей!")
- def get_image() -> Image:
- name = input("Введите название изображения (должно находится в одной папке со скриптом):")
- try:
- im = Image.open(name)
- except Exception:
- print("Неудача!")
- exit(0)
- return im
- #---------------------------------------#
- attention()
- image = get_image()
- width, height = image.size
- flag_okay = False
- if width == _SIZE_WIDTH and height == _SIZE_HEIGHT:
- flag_okay = True
- if not flag_okay:
- print("Недопустимый размер изображения")
- print(width, height)
- exit(0)
- print("Все ок!")
- image = image.convert('1')
- image.save('result.png')
- byteset = ""
- for x in range(105,-1,-1):
- for y in range(0,17):
- byte = str(image.getpixel((x,y)))
- if byte == "255":
- byteset += '1'
- else:
- byteset += '0'
- k = int(byteset,2)*17
- print("Все готово:")
- print(k)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement