Skip to content

The imreadanimation function fails to read some animated GIFs correctly. #26924

@sturkmen72

Description

@sturkmen72

System Information

OpenCV version: 4.12.0-dev

Detailed description

Image

converting the gif image above to apng shows the problem

Image

Steps to reproduce

import cv2 as cv
import sys

animation = cv.Animation()
filename = "C:\\images\\gif\\unnamed.gif"
success, animation = cv.imreadanimation(filename)
if not success:
    print("Failed to load animation frames")
    sys.exit()

cv.imwriteanimation("C:\\images\\res.png",animation)

while True:
    for i, frame in enumerate(animation.frames):
        cv.imshow("Animation", frame)
        key_code = cv.waitKey(animation.durations[i])
        if key_code == 27:  # Exit if 'Esc' key is pressed
            cv.destroyAllWindows()
            sys.exit()

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions