#!/usr/bin/env python3 from pathlib import Path from textwrap import wrap def main(): with (Path(__file__).parent / "digits.bin").open('r') as file: content = file.read() chunks = wrap(content, width = 8) digits = [int(chunk, 2) for chunk in chunks] # file out.jpg reveals type with (Path(__file__).parent / "out.jpg").open('wb') as file: file.write(bytes(digits)) if __name__ == '__main__': main()