private List<GifImageData> findAllImageData(final GifImageContents imageContents) throws ImagingException {
        final List<ImageDescriptor> descriptors = findAllBlocks(imageContents.blocks, IMAGE_SEPARATOR);

        if (descriptors.isEmpty()) {
            throw new ImagingException("GIF: Couldn't read Image Descriptor");
        }

        final List<GraphicControlExtension> gcExtensions = findAllBlocks(imageContents.blocks, GRAPHIC_CONTROL_EXTENSION);

        if (!gcExtensions.isEmpty() && gcExtensions.size() != descriptors.size()) {
            throw new ImagingException("GIF: Invalid amount of Graphic Control Extensions");
        }

        final List<GifImageData> imageData = Allocator.arrayList(descriptors.size());
        for (int i = 0; i < descriptors.size(); i++) {
            final ImageDescriptor descriptor = descriptors.get(i);
            if (descriptor == null) {
                throw new ImagingException(String.format("GIF: Couldn't read Image Descriptor of image number %d", i));
            }

            final GraphicControlExtension gce = gcExtensions.isEmpty() ? null : gcExtensions.get(i);

            imageData.add(new GifImageData(descriptor, gce));
        }

        return imageData;
    }
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