cv2.imread() cannot read gifs

asked 2015-10-02 19:19:01 -0500

hekevintran gravatar image

I installed OpenCV 3 using Homebrew and linked it to my Python installation. I'm following through this basic tutorial: https://opencv-python-tutroals.readth...

I'm having trouble with the first code snippet that reads an image:

import numpy as np
import cv2

# Load an color image in grayscale
img = cv2.imread('messi5.jpg',0)

I can run the code above fine if the image is a jpeg or a png, but not if it is a gif.

How do I get cv2.imread() to work on gifs?

edit retag flag offensive close merge delete


"How do I get cv2.imread() to work on gifs?" - unfortunately, no way. there is just no support for gif

(it's still a patent/nonfree problem)

berak gravatar imageberak ( 2015-10-03 00:30:36 -0500 )edit

Hi, Could you please provide more info on this? Wiki says gif's free since 2004 or so. Other imaging libs are actively using gif. The license seems to be permissive. See (

egorpugin gravatar imageegorpugin ( 2017-01-20 08:36:07 -0500 )edit