private GifImageData findFirstImageData(final GifImageContents imageContents) throws ImagingException {
        final ImageDescriptor descriptor = (ImageDescriptor) findBlock(imageContents.blocks, IMAGE_SEPARATOR);

        if (descriptor == null) {
            throw new ImagingException("GIF: Couldn't read Image Descriptor");
        }

        final GraphicControlExtension gce = (GraphicControlExtension) findBlock(imageContents.blocks, GRAPHIC_CONTROL_EXTENSION);

        return new GifImageData(descriptor, gce);
    }
See {@link GifImageParser#readBlocks} for reference how the blocks are created. They should match the code we are giving here, returning the correct
class type. Internal only.
src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java