Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File format limits in pixel size for png images?

Is there a file format limit to the PNG pixel size?

I am trying to visualize a 30.000x30.000 pixels PNG image with Firefox, but I get an error. The image opens correcly in Preview.app, although very slowly. The file size is not big, just around 3 MiB (1 bit black/white image). I am wondering if there's a technical file-format reason for this.

like image 528
Stefano Borini Avatar asked Nov 05 '10 19:11

Stefano Borini


2 Answers

A naive implementation of resizing would require the image to be blown up to 2.7GB in size before it is displayed. This would clearly be too large for a normal 32-bit program to handle.

The PNG specification doesn't appear to place any limits on the width and height of an image; these are 4 byte unsigned integers, which could be up to 4294967295. http://www.libpng.org/pub/png/spec/iso/index-object.html#11IHDR

like image 52
Mark Ransom Avatar answered Sep 26 '22 13:09

Mark Ransom


That is an odd image, but I am sure there is a reason to have such a huge image.

I can't really address the size limit, but I can address a way to get around it. Create a set of tiles of some size, and then as the user scrolls, bring tiles into view using CSS to position them correctly. You might even be able to get away with bringing up all the tiles at once, with a slew of smaller images.

But I am curious, what is the application that needs such a huge image displayed without scaling out?

Erick

like image 32
Erick T Avatar answered Sep 24 '22 13:09

Erick T