PNG's selling point is flexibility. All they *have* to contain is the Header, Pixel Data, End of Data tag; anything else is considered optional. Some hold text, like creation date/time, image creator, version, ect. Others contain dithering, palettes, compression, background data, ect...
What'd I do for a library like yours is to look for the background code first, and if available, go with it. If it's not found, then I'd manually look for the background color (or just ask the user to supply it). If it's there, you *know* it's right; if not, you have to make a "best guess" at the color.