示例#1
0
    def test_pathlib(self):
        from PIL.Image import Path
        im = Image.open(Path("Tests/images/hopper.jpg"))
        self.assertEqual(im.mode, "RGB")
        self.assertEqual(im.size, (128, 128))

        temp_file = self.tempfile("temp.jpg")
        if os.path.exists(temp_file):
            os.remove(temp_file)
        im.save(Path(temp_file))
示例#2
0
    def test_pathlib(self):
        from PIL.Image import Path

        with Image.open(Path("Tests/images/multipage-mmap.tiff")) as im:
            self.assertEqual(im.mode, "P")
            self.assertEqual(im.size, (10, 10))

        with Image.open(Path("Tests/images/hopper.jpg")) as im:
            self.assertEqual(im.mode, "RGB")
            self.assertEqual(im.size, (128, 128))

            temp_file = self.tempfile("temp.jpg")
            if os.path.exists(temp_file):
                os.remove(temp_file)
            im.save(Path(temp_file))
示例#3
0
    def test_pathlib(self, tmp_path):
        from PIL.Image import Path

        with Image.open(Path("Tests/images/multipage-mmap.tiff")) as im:
            assert im.mode == "P"
            assert im.size == (10, 10)

        with Image.open(Path("Tests/images/hopper.jpg")) as im:
            assert im.mode == "RGB"
            assert im.size == (128, 128)

            temp_file = str(tmp_path / "temp.jpg")
            if os.path.exists(temp_file):
                os.remove(temp_file)
            im.save(Path(temp_file))
示例#4
0
    def test_pathlib(self, tmp_path):
        from PIL.Image import Path

        with Image.open(Path("Tests/images/multipage-mmap.tiff")) as im:
            assert im.mode == "P"
            assert im.size == (10, 10)

        with Image.open(Path("Tests/images/hopper.jpg")) as im:
            assert im.mode == "RGB"
            assert im.size == (128, 128)

            for ext in (".jpg", ".jp2"):
                if ext == ".jp2" and not features.check_codec("jpg_2000"):
                    pytest.skip("jpg_2000 not available")
                temp_file = str(tmp_path / ("temp." + ext))
                if os.path.exists(temp_file):
                    os.remove(temp_file)
                im.save(Path(temp_file))