@Override
    public ImageMetadata getMetadata(final ByteSource byteSource, final PngImagingParameters params) throws ImagingException, IOException {
        final ChunkType[] chunkTypes = { ChunkType.tEXt, ChunkType.zTXt, ChunkType.iTXt, ChunkType.eXIf };
        final List<PngChunk> chunks = readChunks(byteSource, chunkTypes, false);

        if (chunks.isEmpty()) {
            return null;
        }

        final GenericImageMetadata textual = new GenericImageMetadata();
        TiffImageMetadata exif = null;

        for (final PngChunk chunk : chunks) {
            if (chunk instanceof AbstractPngTextChunk) {
                final AbstractPngTextChunk textChunk = (AbstractPngTextChunk) chunk;
                textual.add(textChunk.getKeyword(), textChunk.getText());
            } else if (chunk.getChunkType() == ChunkType.eXIf.value) {
                if (exif != null) {
                    throw new ImagingException("Duplicate eXIf chunk");
                }
                exif = (TiffImageMetadata) new TiffImageParser().getMetadata(chunk.getBytes());
            } else {
                throw new ImagingException("Unexpected chunk type: " + chunk.getChunkType());
            }
        }

        return new PngImageMetadata(textual, exif);
    }
Gets TIFF image metadata for a byte source.

@param byteSource The source of the image.
@return TIFF image metadata.
@throws ImagingException In the event that the specified content does not conform to the format of the specific parser implementation.
@throws IOException      In the event of unsuccessful data read operation.
@since 1.0-alpha6
src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java