First time here? Check out the FAQ!

Ask Your Question
0

cv2.imread fail to open gif image

asked Feb 20 '0

raggupta2 gravatar image

updated Sep 17 '0

Can anybody tell why imread function will fail for this photo?

C:\fakepath\f.gif

Actual file is here: https://drive.google.com/file/d/1qFPK...

Preview: (hide)

1 answer

Sort by » oldest newest most voted
3

answered Feb 20 '0

berak gravatar image

updated Feb 20 '0

easy one, imread() won't read any .gif there is no codec for this (license problem)

as a workaround (and if you have ffmpeg support builtin), try:

cap = cv2.VideoCapture("f.gif")
ret, image = cap.read()
cap.release()

if ret:
    # safe to work with image !
    ...
Preview: (hide)

Comments

i don't think so. This photo is saved from browser. While most of images working only a few getting this problem. Why only specific photos will have this problem?

raggupta2 gravatar imageraggupta2 (Feb 20 '0)edit

gif is animation not image. You will have to used @berak's snippet code.

supra56 gravatar imagesupra56 (Feb 21 '0)edit
1

Of course GIF is a still image format, and was very common for pictures before PNG was invented. Today, though, it is mostly used for small silent animations.

mvuori gravatar imagemvuori (Feb 21 '0)edit

@mvuori. Thank. I can recalled back in 1984. that I used to build 8086.

supra56 gravatar imagesupra56 (Feb 21 '0)edit
2

I just opened this photo in MS-Paint and saved as JPG. Now it works

raggupta2 gravatar imageraggupta2 (Feb 21 '0)edit

Question Tools

1 follower

Stats

Asked: Feb 20 '0

Seen: 15,606 times

Last updated: Feb 21 '20