Apparently libpng can technically do up to 2^31-1 rows and columns. However it imposes an (arbitrary) default limit of 1 million (that could theoretically be lifted by using some additional API). Moved array allocation to the heap now.