From 46ff7631c925cf6bafbe049a391d1841ab4f388b Mon Sep 17 00:00:00 2001 From: Samir OUCHENE Date: Tue, 15 Nov 2022 19:57:13 +0100 Subject: [PATCH] Use urllib.request.url2pathname to get the correct path on windows when the url scheme is file --- imagePerspective.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/imagePerspective.py b/imagePerspective.py index 0c0a3e8..9893c32 100644 --- a/imagePerspective.py +++ b/imagePerspective.py @@ -17,7 +17,7 @@ ''' import os -import sys +import urllib import urllib.parse as urlparse import io @@ -66,7 +66,9 @@ def extract_image(self, node): # FIXME: redundancy if starts_with_file: path = urlparse.urlparse(xlink).path - path = os.path.abspath(path) + # On windows it is important to use urllib.request.url2pathname + # see: https://stackoverflow.com/a/43925228/5920411 + path = urllib.request.url2pathname(path) if os.path.isfile(path): # open the file and encode it # I know, this is a horrible workaround (to b64 encode the image), but