Last active
June 29, 2025 08:54
-
-
Save Vocaned/fc848fe4cdecbfdeced34ba569b1f630 to your computer and use it in GitHub Desktop.
generate an empty png with 1x0 pixel dimension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import struct | |
| import zlib | |
| import base64 | |
| def chunk(t, data): | |
| return (struct.pack('>I', len(data)) + t + data | |
| + struct.pack('>I', zlib.crc32(t + data))) | |
| png = (b'\x89PNG\r\n\x1A\n' | |
| + chunk(b'IHDR', struct.pack('>IIBBBBB', 1, 0, 1, 0, 0, 0, 0)) # https://www.w3.org/TR/png/#11IHDR | |
| + chunk(b'IEND', b'')) | |
| print(base64.b64encode(png).decode()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment