Skip to content

Instantly share code, notes, and snippets.

@Vocaned
Last active June 29, 2025 08:54
Show Gist options
  • Select an option

  • Save Vocaned/fc848fe4cdecbfdeced34ba569b1f630 to your computer and use it in GitHub Desktop.

Select an option

Save Vocaned/fc848fe4cdecbfdeced34ba569b1f630 to your computer and use it in GitHub Desktop.
generate an empty png with 1x0 pixel dimension
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