Platforms
Manifold
Description
import zlib
import struct
def create_chunk(type, data):
crc = zlib.crc32(type + data) & 0xffffffff
return struct.pack(">L", len(data)) + type + data + struct.pack(">L", crc)
Values
width = 69
height = 2147483647
chunk_size = 1000000 # Rows per chunk
chunk_data = b"\x00" * chunk_size
Open file for writing
with open("longest_pink.png", "wb") as out:
# PNG header
out.write(b"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a")
# IHDR chunk
out.write(create_chunk(b"IHDR", struct.pack(">LLBBBBB", width, height, 1, 3, 0, 0, 0)))
# PLTE chunk (pink color)
out.write(create_chunk(b"PLTE", b"\xFF\xC0\xCB"))
# IDAT chunks
compressed_data = zlib.compress(chunk_data, level=zlib.Z_BEST_SPEED)
for i in range(height // chunk_size):
if i % 10 == 0: # Print progress every 10 chunks
print(f"Written {i * chunk_size} rows...")
out.write(create_chunk(b"IDAT", compressed_data))
# Remainder
remainder = height % chunk_size
if remainder:
compressed_data = zlib.compress(b"\x00" * remainder, level=zlib.Z_BEST_SPEED)
out.write(create_chunk(b"IDAT", compressed_data))
# IEND chunk
out.write(create_chunk(b"IEND", b""))
print("Image generation completed!")
On-Chain Data