All users were logged out of Bugzilla on October 13th, 2018

(maybe) need a better way to get png width/height from libpng

RESOLVED INVALID

Status

()

RESOLVED INVALID
9 years ago
9 years ago

People

(Reporter: bholley, Unassigned)

Tracking

Trunk
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

9 years ago
In bug 435296, we want to get only the width/height from a png with the lowest possible amount of overhead. Currently, I don't see any way in the libpng api to do this without doing more serious initialization of the png read structure. My impression is that this is more expensive than it needs to be, since it fires up all the z decompression stuff which shouldn't be necessary to read headers. As a result, the current hack I've implemented involves using setjmp/longjmp (grep for the word 'gross' in the patch over at bug 435296).

Glenn - a few questions:
1) Am I correct that there's way with the current png API to get the width/height without full read struct initialization?
2) How significant would you estimate the overhead of this to be?
3) Depending on the answers of 1 and 2, would it be possible to put support into libpng for easier access to the header data?
If all you want is the width and height, you should be looking at the *NIX "file" utility.  The width and height are in known offsets from the beginning of the datastream, as 4-byte integers in network byte order (most significant byte first).  You don't need libpng for that.
(Reporter)

Comment 2

9 years ago
per glenn's advice I hand-rolled my own code over at bug 435296 and it works great. Resolving this as invalid.
Status: NEW → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.