Image_extensions not working for get_image_files

Hey guys, so I tried to get image files like so

filenames = get_image_files((path/‘images’),check_ext=True,image_extensions=[’.png’])

    TypeError                                 Traceback (most recent call last)
<ipython-input-27-6277c100d0e9> in <module>()
----> 1 filenames = get_image_files((path/'images'),check_ext=True,image_extensions=['.png'])

TypeError: get_image_files() got an unexpected keyword argument 'image_extensions'

But the source code reads like this -

def get_image_files(c:PathOrStr, check_ext:bool=True, recurse=False)->FilePathList:
    "Return list of files in `c` that are images. `check_ext` will filter to `image_extensions`."
    return get_files(c, extensions=(image_extensions if check_ext else None), recurse=recurse)

There seems to be no way to add image_extensions, even though the function has a way to handle it.
Any suggestions?

Instead of using the get_image_files() , use the get_files() to filter the files into a List object

  img_path = path/'images'
  filenames = get_files(img_path, extensions=('.png'), recurse=recurse)

Back to your question, In the source code, if you go a few lines above in the file, you will find this line , which should tell you what is happening :slight_smile:

image_extensions = set(k for k,v in mimetypes.types_map.items() if v.startswith('image/'))



Hey Sorry for the late reply. Very grateful! :grinning: