ValueError: Could not find a format to read the specified file in mode 'i'

Different, but in case helpful. I had an identical error in a different library (skimage), and the solution was to add an extra 'plugin' parameter like so -

image = io.imread(filename,plugin='matplotlib')

I had this problem today, and found that if I closed the file before reading it into imageio the problem went away.

Error was:

File "/home/vinny/pvenvs/chess/lib/python3.6/site-packages/imageio/core/functions.py", line 139, in get_reader                                                  "Could not find a format to read the specified file " "in mode %r" % mode  ValueError: Could not find a format to read the specified file in mode 'i' 

Solution: Put file.close() before images.append(imageio.imread(filename)), not after.


Add the option "pilmode":

imageio.imread(filename,pilmode="RGB")

It worked for me.


Had the exact same problem recently, and the issue was a single corrupt file. Best is to use something like PIL to check for bad files.

import os
from os import listdir
from PIL import Image

dir_path = "/path/"


for filename in listdir(dir_path):
    if filename.endswith('.jpg'):
        try:
            img = Image.open(dir_path+"\\"+filename) # open the image file
            img.verify() # verify that it is, in fact an image
        except (IOError, SyntaxError) as e:
            print('Bad file:', filename)
            #os.remove(dir_path+"\\"+filename) (Maybe)