@@ -0,0 +1,1087 @@
+#!/usr/bin/env python3%0A#%0A# Turn a PNG image into a Futhark value of type %5Bheight%5D%5Bwidth%5Di32 encoded in%0A# the binary data format.%0A# Usage: ./png2data image.png output.data%0A#%0A# Absolutely no error checking is done.%0A#%0A# png2data currently supports 24-bit RGB PNGs. Transparency, grayscale, multiple%0A# palettes and most other features of PNG is not supported.%0A%0Aimport sys%0Aimport numpy as np%0Aimport png%0A%0Aif __name__ == '__main__':%0A    infile = sys.argv%5B1%5D%0A    outfile = sys.argv%5B2%5D%0A%0A    r = png.Reader(infile)%0A    (width, height, img, _) = r.read()%0A    image_2d = np.vstack(map(np.uint32, img))%0A    image_3d = np.reshape(image_2d,%0A                             (height, width, 3))%0A    array = np.empty((height, width), dtype=np.uint32)%0A    array = array %7C (image_3d%5B:,:,0%5D %3C%3C 16)%0A    array = array %7C (image_3d%5B:,:,1%5D %3C%3C 8)%0A    array = array %7C (image_3d%5B:,:,2%5D)%0A%0A    with open(outfile, 'wb') as f:%0A        f.write(b'b')%0A        f.write(np.int8(2))%0A        f.write(np.int8(2))%0A        f.write(b' i32')%0A        f.write(np.uint64(height))%0A        f.write(np.uint64(width))%0A        array.tofile(f)%0A

Add png2data tool (#818)