[GRASSLIST:2966] Re: PNG size

Glynn Clements glynn.clements at virgin.net
Wed Mar 17 09:38:55 EST 2004

Miha STAUT wrote:

> What is the maximum size of the PNG driver picture. Yesterday I tried about 
> 24000 x 46000 and it produced an error.

It's limited by available memory. However, with the recent 5.3 PNG
driver (which doesn't use GD), each cell is an "unsigned int"
(typically 4 bytes), regardless of whether GRASS_TRUECOLOR is set.

So, a 24000 x 46000 image would require ~4.4Gb of memory, which isn't
possible on a 32-bit architecture. While the latest x86 processors can
have more than 4Gb in total, a single process can't have that much. In
practice, the OS is likely to impose even stricter limits (you may not
even be able to have 1Gb of contiguous memory).

Also, you can't have more than INT_MAX cells (typically 2^31 on a
system with a 32-bit integer); but that isn't an issue in your case
(you only have around half that number).

Finally, the actual PNG file will probably be limited to 2Gb on a
32-bit system.

The 2^31 cell limit could probably be removed easily enough, although
there probably isn't much point; it's unlikely that a 32-bit platform
will allow a single process to use that much memory.

If there was sufficient demand, I suppose that we could have separate
8-bit and 24-bit PNG drivers. Whatever the OS limitations, a version
which used one byte per cell would allow for images four times as
large as one which used four bytes per cell.

Glynn Clements <glynn.clements at virgin.net>

More information about the grass-user mailing list