python的三方库pylibtiff不支持打开中文路径的图片怎么办

python的三方库pylibtiff不支持打开中文路径的图片怎么办
在使用open指令打开图片的时候路径里边的中文乱码,路径没有中文的时候可以正常打开文件。

img


网上查好像opencv库打开图片也会有这个问题,解决方法基本上都是先用numpy载入到内存在打开,
但是pylibtiff好像不支持这样做
我看了三方库的源码使用的是ascii编码 改成utf-8后一样会报错 怎么修改才能解决这个问题
以下是pylibtiff库的open函数

    def open(cls, filename, mode='r'):
        """ Open tiff file as TIFF.
        """
        try:
            try:
                # Python3: it needs bytes for the arguments of type "c_char_p"
                filename = os.fsencode(filename)  # no-op if already bytes
            except AttributeError:
                # Python2: it needs str for the arguments of type "c_char_p"
                if isinstance(filename, unicode):  # noqa: F821
                    filename = filename.encode(sys.getfilesystemencoding())
        except Exception as ex:
            # It's probably going to not work, but let it try
            print('Warning: filename argument is of wrong type or encoding: %s'
                  % ex)

        tiff = libtiff.TIFFOpen(filename, mode.encode('ascii'))
        if tiff.value is None:
            raise TypeError('Failed to open file ' + repr(filename))
        return tiff

numpy支持中文路径,你先把图片用numpy以二进制读取进去,让后用open cv去解码,具体操作你可以搜一下。

你的pycharm的编码格式设置的是utf-8的吗