mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-14 05:36:48 +03:00
Fixed opening mmap image through Path on Windows
This commit is contained in:
parent
c15dc4d7ca
commit
691df96734
|
@ -76,6 +76,10 @@ class TestImage(PillowTestCase):
|
||||||
@unittest.skipUnless(Image.HAS_PATHLIB, "requires pathlib/pathlib2")
|
@unittest.skipUnless(Image.HAS_PATHLIB, "requires pathlib/pathlib2")
|
||||||
def test_pathlib(self):
|
def test_pathlib(self):
|
||||||
from PIL.Image import Path
|
from PIL.Image import Path
|
||||||
|
im = Image.open(Path("Tests/images/multipage-mmap.tiff"))
|
||||||
|
self.assertEqual(im.mode, "P")
|
||||||
|
self.assertEqual(im.size, (10, 10))
|
||||||
|
|
||||||
im = Image.open(Path("Tests/images/hopper.jpg"))
|
im = Image.open(Path("Tests/images/hopper.jpg"))
|
||||||
self.assertEqual(im.mode, "RGB")
|
self.assertEqual(im.mode, "RGB")
|
||||||
self.assertEqual(im.size, (128, 128))
|
self.assertEqual(im.size, (128, 128))
|
||||||
|
|
|
@ -2643,10 +2643,10 @@ def open(fp, mode="r"):
|
||||||
|
|
||||||
exclusive_fp = False
|
exclusive_fp = False
|
||||||
filename = ""
|
filename = ""
|
||||||
if isPath(fp):
|
if HAS_PATHLIB and isinstance(fp, Path):
|
||||||
filename = fp
|
|
||||||
elif HAS_PATHLIB and isinstance(fp, Path):
|
|
||||||
filename = str(fp.resolve())
|
filename = str(fp.resolve())
|
||||||
|
elif isPath(fp):
|
||||||
|
filename = fp
|
||||||
|
|
||||||
if filename:
|
if filename:
|
||||||
fp = builtins.open(filename, "rb")
|
fp = builtins.open(filename, "rb")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user