mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-24 17:06:16 +03:00
Replaced various instances of assert_image_similar with assert_image_similar_tofile
This commit is contained in:
parent
a5c251029c
commit
3495b319bd
|
@ -4,7 +4,12 @@ import pytest
|
||||||
|
|
||||||
from PIL import EpsImagePlugin, Image, features
|
from PIL import EpsImagePlugin, Image, features
|
||||||
|
|
||||||
from .helper import assert_image_similar, hopper, skip_unless_feature
|
from .helper import (
|
||||||
|
assert_image_similar,
|
||||||
|
assert_image_similar_tofile,
|
||||||
|
hopper,
|
||||||
|
skip_unless_feature,
|
||||||
|
)
|
||||||
|
|
||||||
HAS_GHOSTSCRIPT = EpsImagePlugin.has_ghostscript()
|
HAS_GHOSTSCRIPT = EpsImagePlugin.has_ghostscript()
|
||||||
|
|
||||||
|
@ -72,8 +77,9 @@ def test_cmyk():
|
||||||
assert cmyk_image.mode == "RGB"
|
assert cmyk_image.mode == "RGB"
|
||||||
|
|
||||||
if features.check("jpg"):
|
if features.check("jpg"):
|
||||||
with Image.open("Tests/images/pil_sample_rgb.jpg") as target:
|
assert_image_similar_tofile(
|
||||||
assert_image_similar(cmyk_image, target, 10)
|
cmyk_image, "Tests/images/pil_sample_rgb.jpg", 10
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available")
|
@pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available")
|
||||||
|
|
|
@ -5,7 +5,7 @@ import pytest
|
||||||
|
|
||||||
from PIL import IcnsImagePlugin, Image, features
|
from PIL import IcnsImagePlugin, Image, features
|
||||||
|
|
||||||
from .helper import assert_image_equal, assert_image_similar
|
from .helper import assert_image_equal, assert_image_similar_tofile
|
||||||
|
|
||||||
# sample icon file
|
# sample icon file
|
||||||
TEST_FILE = "Tests/images/pillow.icns"
|
TEST_FILE = "Tests/images/pillow.icns"
|
||||||
|
@ -49,8 +49,7 @@ def test_save_append_images(tmp_path):
|
||||||
with Image.open(TEST_FILE) as im:
|
with Image.open(TEST_FILE) as im:
|
||||||
im.save(temp_file, append_images=[provided_im])
|
im.save(temp_file, append_images=[provided_im])
|
||||||
|
|
||||||
with Image.open(temp_file) as reread:
|
assert_image_similar_tofile(im, temp_file, 1)
|
||||||
assert_image_similar(reread, im, 1)
|
|
||||||
|
|
||||||
with Image.open(temp_file) as reread:
|
with Image.open(temp_file) as reread:
|
||||||
reread.size = (16, 16, 2)
|
reread.size = (16, 16, 2)
|
||||||
|
|
|
@ -19,6 +19,7 @@ from .helper import (
|
||||||
assert_image_equal,
|
assert_image_equal,
|
||||||
assert_image_equal_tofile,
|
assert_image_equal_tofile,
|
||||||
assert_image_similar,
|
assert_image_similar,
|
||||||
|
assert_image_similar_tofile,
|
||||||
cjpeg_available,
|
cjpeg_available,
|
||||||
djpeg_available,
|
djpeg_available,
|
||||||
hopper,
|
hopper,
|
||||||
|
@ -578,7 +579,7 @@ class TestFileJpeg:
|
||||||
def test_load_djpeg(self):
|
def test_load_djpeg(self):
|
||||||
with Image.open(TEST_FILE) as img:
|
with Image.open(TEST_FILE) as img:
|
||||||
img.load_djpeg()
|
img.load_djpeg()
|
||||||
assert_image_similar(img, Image.open(TEST_FILE), 5)
|
assert_image_similar_tofile(img, TEST_FILE, 5)
|
||||||
|
|
||||||
@pytest.mark.skipif(not cjpeg_available(), reason="cjpeg not available")
|
@pytest.mark.skipif(not cjpeg_available(), reason="cjpeg not available")
|
||||||
def test_save_cjpeg(self, tmp_path):
|
def test_save_cjpeg(self, tmp_path):
|
||||||
|
@ -586,7 +587,7 @@ class TestFileJpeg:
|
||||||
tempfile = str(tmp_path / "temp.jpg")
|
tempfile = str(tmp_path / "temp.jpg")
|
||||||
JpegImagePlugin._save_cjpeg(img, 0, tempfile)
|
JpegImagePlugin._save_cjpeg(img, 0, tempfile)
|
||||||
# Default save quality is 75%, so a tiny bit of difference is alright
|
# Default save quality is 75%, so a tiny bit of difference is alright
|
||||||
assert_image_similar(img, Image.open(tempfile), 17)
|
assert_image_similar_tofile(img, tempfile, 17)
|
||||||
|
|
||||||
def test_no_duplicate_0x1001_tag(self):
|
def test_no_duplicate_0x1001_tag(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
|
|
|
@ -8,6 +8,7 @@ from PIL import Image, ImageFile, Jpeg2KImagePlugin, features
|
||||||
from .helper import (
|
from .helper import (
|
||||||
assert_image_equal,
|
assert_image_equal,
|
||||||
assert_image_similar,
|
assert_image_similar,
|
||||||
|
assert_image_similar_tofile,
|
||||||
is_big_endian,
|
is_big_endian,
|
||||||
skip_unless_feature,
|
skip_unless_feature,
|
||||||
)
|
)
|
||||||
|
@ -62,9 +63,7 @@ def test_invalid_file():
|
||||||
def test_bytesio():
|
def test_bytesio():
|
||||||
with open("Tests/images/test-card-lossless.jp2", "rb") as f:
|
with open("Tests/images/test-card-lossless.jp2", "rb") as f:
|
||||||
data = BytesIO(f.read())
|
data = BytesIO(f.read())
|
||||||
with Image.open(data) as im:
|
assert_image_similar_tofile(test_card, data, 1.0e-3)
|
||||||
im.load()
|
|
||||||
assert_image_similar(im, test_card, 1.0e-3)
|
|
||||||
|
|
||||||
|
|
||||||
# These two test pre-written JPEG 2000 files that were not written with
|
# These two test pre-written JPEG 2000 files that were not written with
|
||||||
|
@ -80,9 +79,9 @@ def test_lossless(tmp_path):
|
||||||
|
|
||||||
|
|
||||||
def test_lossy_tiled():
|
def test_lossy_tiled():
|
||||||
with Image.open("Tests/images/test-card-lossy-tiled.jp2") as im:
|
assert_image_similar_tofile(
|
||||||
im.load()
|
test_card, "Tests/images/test-card-lossy-tiled.jp2", 2.0
|
||||||
assert_image_similar(im, test_card, 2.0)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_lossless_rt():
|
def test_lossless_rt():
|
||||||
|
@ -193,15 +192,13 @@ def test_16bit_monochrome_has_correct_mode():
|
||||||
@pytest.mark.xfail(is_big_endian(), reason="Fails on big-endian")
|
@pytest.mark.xfail(is_big_endian(), reason="Fails on big-endian")
|
||||||
def test_16bit_monochrome_jp2_like_tiff():
|
def test_16bit_monochrome_jp2_like_tiff():
|
||||||
with Image.open("Tests/images/16bit.cropped.tif") as tiff_16bit:
|
with Image.open("Tests/images/16bit.cropped.tif") as tiff_16bit:
|
||||||
with Image.open("Tests/images/16bit.cropped.jp2") as jp2:
|
assert_image_similar_tofile(tiff_16bit, "Tests/images/16bit.cropped.jp2", 1e-3)
|
||||||
assert_image_similar(jp2, tiff_16bit, 1e-3)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail(is_big_endian(), reason="Fails on big-endian")
|
@pytest.mark.xfail(is_big_endian(), reason="Fails on big-endian")
|
||||||
def test_16bit_monochrome_j2k_like_tiff():
|
def test_16bit_monochrome_j2k_like_tiff():
|
||||||
with Image.open("Tests/images/16bit.cropped.tif") as tiff_16bit:
|
with Image.open("Tests/images/16bit.cropped.tif") as tiff_16bit:
|
||||||
with Image.open("Tests/images/16bit.cropped.j2k") as j2k:
|
assert_image_similar_tofile(tiff_16bit, "Tests/images/16bit.cropped.j2k", 1e-3)
|
||||||
assert_image_similar(j2k, tiff_16bit, 1e-3)
|
|
||||||
|
|
||||||
|
|
||||||
def test_16bit_j2k_roundtrips():
|
def test_16bit_j2k_roundtrips():
|
||||||
|
|
|
@ -457,8 +457,7 @@ class TestFileLibTiff(LibTiffTestCase):
|
||||||
|
|
||||||
im.save(out, compression="jpeg", quality=30)
|
im.save(out, compression="jpeg", quality=30)
|
||||||
size_jpeg_30 = os.path.getsize(out)
|
size_jpeg_30 = os.path.getsize(out)
|
||||||
with Image.open(out) as im3:
|
assert_image_similar_tofile(im2, out, 30)
|
||||||
assert_image_similar(im2, im3, 30)
|
|
||||||
|
|
||||||
assert size_raw > size_compressed
|
assert size_raw > size_compressed
|
||||||
assert size_compressed > size_jpeg
|
assert size_compressed > size_jpeg
|
||||||
|
@ -642,8 +641,7 @@ class TestFileLibTiff(LibTiffTestCase):
|
||||||
pilim.save(buffer_io, format="tiff", compression=compression)
|
pilim.save(buffer_io, format="tiff", compression=compression)
|
||||||
buffer_io.seek(0)
|
buffer_io.seek(0)
|
||||||
|
|
||||||
with Image.open(buffer_io) as pilim_load:
|
assert_image_similar_tofile(pilim, buffer_io, 0)
|
||||||
assert_image_similar(pilim, pilim_load, 0)
|
|
||||||
|
|
||||||
save_bytesio()
|
save_bytesio()
|
||||||
save_bytesio("raw")
|
save_bytesio("raw")
|
||||||
|
|
|
@ -2,7 +2,12 @@ import pytest
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from .helper import assert_image_equal, assert_image_similar, hopper
|
from .helper import (
|
||||||
|
assert_image_equal,
|
||||||
|
assert_image_similar,
|
||||||
|
assert_image_similar_tofile,
|
||||||
|
hopper,
|
||||||
|
)
|
||||||
|
|
||||||
_webp = pytest.importorskip("PIL._webp", reason="WebP support not installed")
|
_webp = pytest.importorskip("PIL._webp", reason="WebP support not installed")
|
||||||
|
|
||||||
|
@ -29,8 +34,7 @@ def test_read_rgba():
|
||||||
|
|
||||||
image.tobytes()
|
image.tobytes()
|
||||||
|
|
||||||
with Image.open("Tests/images/transparent.png") as target:
|
assert_image_similar_tofile(image, "Tests/images/transparent.png", 20.0)
|
||||||
assert_image_similar(image, target, 20.0)
|
|
||||||
|
|
||||||
|
|
||||||
def test_write_lossless_rgb(tmp_path):
|
def test_write_lossless_rgb(tmp_path):
|
||||||
|
|
|
@ -2,7 +2,7 @@ import pytest
|
||||||
|
|
||||||
from PIL import Image, WmfImagePlugin
|
from PIL import Image, WmfImagePlugin
|
||||||
|
|
||||||
from .helper import assert_image_similar, hopper
|
from .helper import assert_image_similar_tofile, hopper
|
||||||
|
|
||||||
|
|
||||||
def test_load_raw():
|
def test_load_raw():
|
||||||
|
@ -13,9 +13,7 @@ def test_load_raw():
|
||||||
# Currently, support for WMF/EMF is Windows-only
|
# Currently, support for WMF/EMF is Windows-only
|
||||||
im.load()
|
im.load()
|
||||||
# Compare to reference rendering
|
# Compare to reference rendering
|
||||||
with Image.open("Tests/images/drawing_emf_ref.png") as imref:
|
assert_image_similar_tofile(im, "Tests/images/drawing_emf_ref.png", 0)
|
||||||
imref.load()
|
|
||||||
assert_image_similar(im, imref, 0)
|
|
||||||
|
|
||||||
# Test basic WMF open and rendering
|
# Test basic WMF open and rendering
|
||||||
with Image.open("Tests/images/drawing.wmf") as im:
|
with Image.open("Tests/images/drawing.wmf") as im:
|
||||||
|
@ -23,9 +21,7 @@ def test_load_raw():
|
||||||
# Currently, support for WMF/EMF is Windows-only
|
# Currently, support for WMF/EMF is Windows-only
|
||||||
im.load()
|
im.load()
|
||||||
# Compare to reference rendering
|
# Compare to reference rendering
|
||||||
with Image.open("Tests/images/drawing_wmf_ref.png") as imref:
|
assert_image_similar_tofile(im, "Tests/images/drawing_wmf_ref.png", 2.0)
|
||||||
imref.load()
|
|
||||||
assert_image_similar(im, imref, 2.0)
|
|
||||||
|
|
||||||
|
|
||||||
def test_register_handler(tmp_path):
|
def test_register_handler(tmp_path):
|
||||||
|
@ -66,8 +62,7 @@ def test_load_set_dpi():
|
||||||
im.load(144)
|
im.load(144)
|
||||||
assert im.size == (164, 164)
|
assert im.size == (164, 164)
|
||||||
|
|
||||||
with Image.open("Tests/images/drawing_wmf_ref_144.png") as expected:
|
assert_image_similar_tofile(im, "Tests/images/drawing_wmf_ref_144.png", 2.1)
|
||||||
assert_image_similar(im, expected, 2.1)
|
|
||||||
|
|
||||||
|
|
||||||
def test_save(tmp_path):
|
def test_save(tmp_path):
|
||||||
|
|
|
@ -6,7 +6,7 @@ from PIL import FontFile, Image, ImageDraw, ImageFont, PcfFontFile
|
||||||
|
|
||||||
from .helper import (
|
from .helper import (
|
||||||
assert_image_equal_tofile,
|
assert_image_equal_tofile,
|
||||||
assert_image_similar,
|
assert_image_similar_tofile,
|
||||||
skip_unless_feature,
|
skip_unless_feature,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -61,8 +61,7 @@ def test_draw(request, tmp_path):
|
||||||
im = Image.new("L", (130, 30), "white")
|
im = Image.new("L", (130, 30), "white")
|
||||||
draw = ImageDraw.Draw(im)
|
draw = ImageDraw.Draw(im)
|
||||||
draw.text((0, 0), message, "black", font=font)
|
draw.text((0, 0), message, "black", font=font)
|
||||||
with Image.open("Tests/images/test_draw_pbm_target.png") as target:
|
assert_image_similar_tofile(im, "Tests/images/test_draw_pbm_target.png", 0)
|
||||||
assert_image_similar(im, target, 0)
|
|
||||||
|
|
||||||
|
|
||||||
def test_textsize(request, tmp_path):
|
def test_textsize(request, tmp_path):
|
||||||
|
@ -83,8 +82,7 @@ def _test_high_characters(request, tmp_path, message):
|
||||||
im = Image.new("L", (750, 30), "white")
|
im = Image.new("L", (750, 30), "white")
|
||||||
draw = ImageDraw.Draw(im)
|
draw = ImageDraw.Draw(im)
|
||||||
draw.text((0, 0), message, "black", font=font)
|
draw.text((0, 0), message, "black", font=font)
|
||||||
with Image.open("Tests/images/high_ascii_chars.png") as target:
|
assert_image_similar_tofile(im, "Tests/images/high_ascii_chars.png", 0)
|
||||||
assert_image_similar(im, target, 0)
|
|
||||||
|
|
||||||
|
|
||||||
def test_high_characters(request, tmp_path):
|
def test_high_characters(request, tmp_path):
|
||||||
|
|
|
@ -4,7 +4,7 @@ from PIL import FontFile, Image, ImageDraw, ImageFont, PcfFontFile
|
||||||
|
|
||||||
from .helper import (
|
from .helper import (
|
||||||
assert_image_equal_tofile,
|
assert_image_equal_tofile,
|
||||||
assert_image_similar,
|
assert_image_similar_tofile,
|
||||||
skip_unless_feature,
|
skip_unless_feature,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -82,8 +82,7 @@ def _test_draw(request, tmp_path, encoding):
|
||||||
draw = ImageDraw.Draw(im)
|
draw = ImageDraw.Draw(im)
|
||||||
message = charsets[encoding]["message"].encode(encoding)
|
message = charsets[encoding]["message"].encode(encoding)
|
||||||
draw.text((0, 0), message, "black", font=font)
|
draw.text((0, 0), message, "black", font=font)
|
||||||
with Image.open(charsets[encoding]["image1"]) as target:
|
assert_image_similar_tofile(im, charsets[encoding]["image1"], 0)
|
||||||
assert_image_similar(im, target, 0)
|
|
||||||
|
|
||||||
|
|
||||||
def test_draw_iso8859_1(request, tmp_path):
|
def test_draw_iso8859_1(request, tmp_path):
|
||||||
|
|
|
@ -11,7 +11,7 @@ from PIL import Image, ImageDraw, ImagePalette, ImageShow, UnidentifiedImageErro
|
||||||
from .helper import (
|
from .helper import (
|
||||||
assert_image_equal,
|
assert_image_equal,
|
||||||
assert_image_equal_tofile,
|
assert_image_equal_tofile,
|
||||||
assert_image_similar,
|
assert_image_similar_tofile,
|
||||||
assert_not_all_same,
|
assert_not_all_same,
|
||||||
hopper,
|
hopper,
|
||||||
is_win32,
|
is_win32,
|
||||||
|
@ -172,8 +172,7 @@ class TestImage:
|
||||||
with tempfile.TemporaryFile() as fp:
|
with tempfile.TemporaryFile() as fp:
|
||||||
im.save(fp, "JPEG")
|
im.save(fp, "JPEG")
|
||||||
fp.seek(0)
|
fp.seek(0)
|
||||||
with Image.open(fp) as reloaded:
|
assert_image_similar_tofile(im, fp, 20)
|
||||||
assert_image_similar(im, reloaded, 20)
|
|
||||||
|
|
||||||
def test_unknown_extension(self, tmp_path):
|
def test_unknown_extension(self, tmp_path):
|
||||||
im = hopper()
|
im = hopper()
|
||||||
|
@ -456,8 +455,7 @@ class TestImage:
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
assert im.size == (128, 128)
|
assert im.size == (128, 128)
|
||||||
with Image.open("Tests/images/effect_spread.png") as im3:
|
assert_image_similar_tofile(im2, "Tests/images/effect_spread.png", 110)
|
||||||
assert_image_similar(im2, im3, 110)
|
|
||||||
|
|
||||||
def test_effect_spread_zero(self):
|
def test_effect_spread_zero(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
|
|
|
@ -8,7 +8,13 @@ import pytest
|
||||||
|
|
||||||
from PIL import Image, ImageMode, features
|
from PIL import Image, ImageMode, features
|
||||||
|
|
||||||
from .helper import assert_image, assert_image_equal, assert_image_similar, hopper
|
from .helper import (
|
||||||
|
assert_image,
|
||||||
|
assert_image_equal,
|
||||||
|
assert_image_similar,
|
||||||
|
assert_image_similar_tofile,
|
||||||
|
hopper,
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from PIL import ImageCms
|
from PIL import ImageCms
|
||||||
|
@ -240,8 +246,7 @@ def test_lab_color():
|
||||||
|
|
||||||
# i.save('temp.lab.tif') # visually verified vs PS.
|
# i.save('temp.lab.tif') # visually verified vs PS.
|
||||||
|
|
||||||
with Image.open("Tests/images/hopper.Lab.tif") as target:
|
assert_image_similar_tofile(i, "Tests/images/hopper.Lab.tif", 3.5)
|
||||||
assert_image_similar(i, target, 3.5)
|
|
||||||
|
|
||||||
|
|
||||||
def test_lab_srgb():
|
def test_lab_srgb():
|
||||||
|
|
|
@ -5,7 +5,7 @@ from PIL import Image, ImageDraw, ImageDraw2
|
||||||
from .helper import (
|
from .helper import (
|
||||||
assert_image_equal,
|
assert_image_equal,
|
||||||
assert_image_equal_tofile,
|
assert_image_equal_tofile,
|
||||||
assert_image_similar,
|
assert_image_similar_tofile,
|
||||||
hopper,
|
hopper,
|
||||||
skip_unless_feature,
|
skip_unless_feature,
|
||||||
)
|
)
|
||||||
|
@ -62,7 +62,7 @@ def helper_ellipse(mode, bbox):
|
||||||
draw.ellipse(bbox, pen, brush)
|
draw.ellipse(bbox, pen, brush)
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
assert_image_similar(im, Image.open(expected), 1)
|
assert_image_similar_tofile(im, expected, 1)
|
||||||
|
|
||||||
|
|
||||||
def test_ellipse1():
|
def test_ellipse1():
|
||||||
|
@ -83,7 +83,7 @@ def test_ellipse_edge():
|
||||||
draw.ellipse(((0, 0), (W - 1, H - 1)), brush)
|
draw.ellipse(((0, 0), (W - 1, H - 1)), brush)
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
assert_image_similar(im, Image.open("Tests/images/imagedraw_ellipse_edge.png"), 1)
|
assert_image_similar_tofile(im, "Tests/images/imagedraw_ellipse_edge.png", 1)
|
||||||
|
|
||||||
|
|
||||||
def helper_line(points):
|
def helper_line(points):
|
||||||
|
@ -179,7 +179,7 @@ def test_big_rectangle():
|
||||||
draw.rectangle(bbox, brush)
|
draw.rectangle(bbox, brush)
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
assert_image_similar(im, Image.open(expected), 1)
|
assert_image_similar_tofile(im, expected, 1)
|
||||||
|
|
||||||
|
|
||||||
@skip_unless_feature("freetype2")
|
@skip_unless_feature("freetype2")
|
||||||
|
@ -194,7 +194,7 @@ def test_text():
|
||||||
draw.text((5, 5), "ImageDraw2", font)
|
draw.text((5, 5), "ImageDraw2", font)
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
assert_image_similar(im, Image.open(expected), 13)
|
assert_image_similar_tofile(im, expected, 13)
|
||||||
|
|
||||||
|
|
||||||
@skip_unless_feature("freetype2")
|
@skip_unless_feature("freetype2")
|
||||||
|
|
|
@ -13,7 +13,6 @@ from PIL import Image, ImageDraw, ImageFont, features
|
||||||
from .helper import (
|
from .helper import (
|
||||||
assert_image_equal,
|
assert_image_equal,
|
||||||
assert_image_equal_tofile,
|
assert_image_equal_tofile,
|
||||||
assert_image_similar,
|
|
||||||
assert_image_similar_tofile,
|
assert_image_similar_tofile,
|
||||||
is_win32,
|
is_win32,
|
||||||
skip_unless_feature,
|
skip_unless_feature,
|
||||||
|
@ -130,8 +129,7 @@ class TestImageFont:
|
||||||
draw.text((10, 10), txt, font=ttf)
|
draw.text((10, 10), txt, font=ttf)
|
||||||
|
|
||||||
target = "Tests/images/transparent_background_text.png"
|
target = "Tests/images/transparent_background_text.png"
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(im, target, 4.09)
|
||||||
assert_image_similar(im, target_img, 4.09)
|
|
||||||
|
|
||||||
def test_textsize_equal(self):
|
def test_textsize_equal(self):
|
||||||
im = Image.new(mode="RGB", size=(300, 100))
|
im = Image.new(mode="RGB", size=(300, 100))
|
||||||
|
@ -143,11 +141,10 @@ class TestImageFont:
|
||||||
draw.text((10, 10), txt, font=ttf)
|
draw.text((10, 10), txt, font=ttf)
|
||||||
draw.rectangle((10, 10, 10 + size[0], 10 + size[1]))
|
draw.rectangle((10, 10, 10 + size[0], 10 + size[1]))
|
||||||
|
|
||||||
target = "Tests/images/rectangle_surrounding_text.png"
|
# Epsilon ~.5 fails with FreeType 2.7
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(
|
||||||
|
im, "Tests/images/rectangle_surrounding_text.png", 2.5
|
||||||
# Epsilon ~.5 fails with FreeType 2.7
|
)
|
||||||
assert_image_similar(im, target_img, 2.5)
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"text, mode, font, size, length_basic, length_raqm",
|
"text, mode, font, size, length_basic, length_raqm",
|
||||||
|
@ -191,13 +188,10 @@ class TestImageFont:
|
||||||
draw.text((0, y), line, font=ttf)
|
draw.text((0, y), line, font=ttf)
|
||||||
y += line_spacing
|
y += line_spacing
|
||||||
|
|
||||||
target = "Tests/images/multiline_text.png"
|
# some versions of freetype have different horizontal spacing.
|
||||||
with Image.open(target) as target_img:
|
# setting a tight epsilon, I'm showing the original test failure
|
||||||
|
# at epsilon = ~38.
|
||||||
# some versions of freetype have different horizontal spacing.
|
assert_image_similar_tofile(im, "Tests/images/multiline_text.png", 6.2)
|
||||||
# setting a tight epsilon, I'm showing the original test failure
|
|
||||||
# at epsilon = ~38.
|
|
||||||
assert_image_similar(im, target_img, 6.2)
|
|
||||||
|
|
||||||
def test_render_multiline_text(self):
|
def test_render_multiline_text(self):
|
||||||
ttf = self.get_font()
|
ttf = self.get_font()
|
||||||
|
@ -208,11 +202,8 @@ class TestImageFont:
|
||||||
draw = ImageDraw.Draw(im)
|
draw = ImageDraw.Draw(im)
|
||||||
draw.text((0, 0), TEST_TEXT, font=ttf)
|
draw.text((0, 0), TEST_TEXT, font=ttf)
|
||||||
|
|
||||||
target = "Tests/images/multiline_text.png"
|
# Epsilon ~.5 fails with FreeType 2.7
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(im, "Tests/images/multiline_text.png", 6.2)
|
||||||
|
|
||||||
# Epsilon ~.5 fails with FreeType 2.7
|
|
||||||
assert_image_similar(im, target_img, 6.2)
|
|
||||||
|
|
||||||
# Test that text() can pass on additional arguments
|
# Test that text() can pass on additional arguments
|
||||||
# to multiline_text()
|
# to multiline_text()
|
||||||
|
@ -227,11 +218,10 @@ class TestImageFont:
|
||||||
draw = ImageDraw.Draw(im)
|
draw = ImageDraw.Draw(im)
|
||||||
draw.multiline_text((0, 0), TEST_TEXT, font=ttf, align=align)
|
draw.multiline_text((0, 0), TEST_TEXT, font=ttf, align=align)
|
||||||
|
|
||||||
target = "Tests/images/multiline_text" + ext + ".png"
|
# Epsilon ~.5 fails with FreeType 2.7
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(
|
||||||
|
im, "Tests/images/multiline_text" + ext + ".png", 6.2
|
||||||
# Epsilon ~.5 fails with FreeType 2.7
|
)
|
||||||
assert_image_similar(im, target_img, 6.2)
|
|
||||||
|
|
||||||
def test_unknown_align(self):
|
def test_unknown_align(self):
|
||||||
im = Image.new(mode="RGB", size=(300, 100))
|
im = Image.new(mode="RGB", size=(300, 100))
|
||||||
|
@ -285,11 +275,8 @@ class TestImageFont:
|
||||||
draw = ImageDraw.Draw(im)
|
draw = ImageDraw.Draw(im)
|
||||||
draw.multiline_text((0, 0), TEST_TEXT, font=ttf, spacing=10)
|
draw.multiline_text((0, 0), TEST_TEXT, font=ttf, spacing=10)
|
||||||
|
|
||||||
target = "Tests/images/multiline_text_spacing.png"
|
# Epsilon ~.5 fails with FreeType 2.7
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(im, "Tests/images/multiline_text_spacing.png", 6.2)
|
||||||
|
|
||||||
# Epsilon ~.5 fails with FreeType 2.7
|
|
||||||
assert_image_similar(im, target_img, 6.2)
|
|
||||||
|
|
||||||
def test_rotated_transposed_font(self):
|
def test_rotated_transposed_font(self):
|
||||||
img_grey = Image.new("L", (100, 100))
|
img_grey = Image.new("L", (100, 100))
|
||||||
|
@ -677,13 +664,11 @@ class TestImageFont:
|
||||||
d.text((10, 10), "Text", font=font, fill="black")
|
d.text((10, 10), "Text", font=font, fill="black")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with Image.open(path) as expected:
|
assert_image_similar_tofile(im, path, epsilon)
|
||||||
assert_image_similar(im, expected, epsilon)
|
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
if "_adobe" in path:
|
if "_adobe" in path:
|
||||||
path = path.replace("_adobe", "_adobe_older_harfbuzz")
|
path = path.replace("_adobe", "_adobe_older_harfbuzz")
|
||||||
with Image.open(path) as expected:
|
assert_image_similar_tofile(im, path, epsilon)
|
||||||
assert_image_similar(im, expected, epsilon)
|
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -774,8 +759,7 @@ class TestImageFont:
|
||||||
|
|
||||||
assert d.textbbox((0, 0), text, f, anchor=anchor) == bbox_expected
|
assert d.textbbox((0, 0), text, f, anchor=anchor) == bbox_expected
|
||||||
|
|
||||||
with Image.open(path) as expected:
|
assert_image_similar_tofile(im, path, 7)
|
||||||
assert_image_similar(im, expected, 7)
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"anchor, align",
|
"anchor, align",
|
||||||
|
@ -813,8 +797,7 @@ class TestImageFont:
|
||||||
(300, 200), text, fill="black", anchor=anchor, font=f, align=align
|
(300, 200), text, fill="black", anchor=anchor, font=f, align=align
|
||||||
)
|
)
|
||||||
|
|
||||||
with Image.open(target) as expected:
|
assert_image_similar_tofile(im, target, 4)
|
||||||
assert_image_similar(im, expected, 4)
|
|
||||||
|
|
||||||
def test_anchor_invalid(self):
|
def test_anchor_invalid(self):
|
||||||
font = self.get_font()
|
font = self.get_font()
|
||||||
|
@ -872,8 +855,7 @@ class TestImageFont:
|
||||||
d = ImageDraw.Draw(im)
|
d = ImageDraw.Draw(im)
|
||||||
d.text((10, 10), txt, font=ttf, fill="#fa6", embedded_color=True)
|
d.text((10, 10), txt, font=ttf, fill="#fa6", embedded_color=True)
|
||||||
|
|
||||||
with Image.open("Tests/images/standard_embedded.png") as expected:
|
assert_image_similar_tofile(im, "Tests/images/standard_embedded.png", 6.2)
|
||||||
assert_image_similar(im, expected, 6.2)
|
|
||||||
|
|
||||||
@skip_unless_feature_version("freetype2", "2.5.0")
|
@skip_unless_feature_version("freetype2", "2.5.0")
|
||||||
def test_cbdt(self):
|
def test_cbdt(self):
|
||||||
|
@ -889,8 +871,7 @@ class TestImageFont:
|
||||||
|
|
||||||
d.text((10, 10), "\U0001f469", embedded_color=True, font=font)
|
d.text((10, 10), "\U0001f469", embedded_color=True, font=font)
|
||||||
|
|
||||||
with Image.open("Tests/images/cbdt_notocoloremoji.png") as expected:
|
assert_image_similar_tofile(im, "Tests/images/cbdt_notocoloremoji.png", 6.2)
|
||||||
assert_image_similar(im, expected, 6.2)
|
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
assert str(e) in ("unimplemented feature", "unknown file format")
|
assert str(e) in ("unimplemented feature", "unknown file format")
|
||||||
pytest.skip("freetype compiled without libpng or unsupported")
|
pytest.skip("freetype compiled without libpng or unsupported")
|
||||||
|
@ -909,8 +890,9 @@ class TestImageFont:
|
||||||
|
|
||||||
d.text((10, 10), "\U0001f469", "black", font=font)
|
d.text((10, 10), "\U0001f469", "black", font=font)
|
||||||
|
|
||||||
with Image.open("Tests/images/cbdt_notocoloremoji_mask.png") as expected:
|
assert_image_similar_tofile(
|
||||||
assert_image_similar(im, expected, 6.2)
|
im, "Tests/images/cbdt_notocoloremoji_mask.png", 6.2
|
||||||
|
)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
assert str(e) in ("unimplemented feature", "unknown file format")
|
assert str(e) in ("unimplemented feature", "unknown file format")
|
||||||
pytest.skip("freetype compiled without libpng or unsupported")
|
pytest.skip("freetype compiled without libpng or unsupported")
|
||||||
|
@ -928,8 +910,7 @@ class TestImageFont:
|
||||||
|
|
||||||
d.text((15, 5), "Bungee", embedded_color=True, font=font)
|
d.text((15, 5), "Bungee", embedded_color=True, font=font)
|
||||||
|
|
||||||
with Image.open("Tests/images/colr_bungee.png") as expected:
|
assert_image_similar_tofile(im, "Tests/images/colr_bungee.png", 21)
|
||||||
assert_image_similar(im, expected, 21)
|
|
||||||
|
|
||||||
@skip_unless_feature_version("freetype2", "2.10.0")
|
@skip_unless_feature_version("freetype2", "2.10.0")
|
||||||
def test_colr_mask(self):
|
def test_colr_mask(self):
|
||||||
|
@ -944,8 +925,7 @@ class TestImageFont:
|
||||||
|
|
||||||
d.text((15, 5), "Bungee", "black", font=font)
|
d.text((15, 5), "Bungee", "black", font=font)
|
||||||
|
|
||||||
with Image.open("Tests/images/colr_bungee_mask.png") as expected:
|
assert_image_similar_tofile(im, "Tests/images/colr_bungee_mask.png", 22)
|
||||||
assert_image_similar(im, expected, 22)
|
|
||||||
|
|
||||||
|
|
||||||
@skip_unless_feature("raqm")
|
@skip_unless_feature("raqm")
|
||||||
|
|
|
@ -4,7 +4,7 @@ from packaging.version import parse as parse_version
|
||||||
from PIL import Image, ImageDraw, ImageFont, features
|
from PIL import Image, ImageDraw, ImageFont, features
|
||||||
|
|
||||||
from .helper import (
|
from .helper import (
|
||||||
assert_image_similar,
|
assert_image_similar_tofile,
|
||||||
skip_unless_feature,
|
skip_unless_feature,
|
||||||
skip_unless_feature_version,
|
skip_unless_feature_version,
|
||||||
)
|
)
|
||||||
|
@ -31,8 +31,7 @@ def test_complex_text():
|
||||||
draw.text((0, 0), "اهلا عمان", font=ttf, fill=500)
|
draw.text((0, 0), "اهلا عمان", font=ttf, fill=500)
|
||||||
|
|
||||||
target = "Tests/images/test_text.png"
|
target = "Tests/images/test_text.png"
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(im, target, 0.5)
|
||||||
assert_image_similar(im, target_img, 0.5)
|
|
||||||
|
|
||||||
|
|
||||||
def test_y_offset():
|
def test_y_offset():
|
||||||
|
@ -43,8 +42,7 @@ def test_y_offset():
|
||||||
draw.text((0, 0), "العالم العربي", font=ttf, fill=500)
|
draw.text((0, 0), "العالم العربي", font=ttf, fill=500)
|
||||||
|
|
||||||
target = "Tests/images/test_y_offset.png"
|
target = "Tests/images/test_y_offset.png"
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(im, target, 1.7)
|
||||||
assert_image_similar(im, target_img, 1.7)
|
|
||||||
|
|
||||||
|
|
||||||
def test_complex_unicode_text():
|
def test_complex_unicode_text():
|
||||||
|
@ -55,8 +53,7 @@ def test_complex_unicode_text():
|
||||||
draw.text((0, 0), "السلام عليكم", font=ttf, fill=500)
|
draw.text((0, 0), "السلام عليكم", font=ttf, fill=500)
|
||||||
|
|
||||||
target = "Tests/images/test_complex_unicode_text.png"
|
target = "Tests/images/test_complex_unicode_text.png"
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(im, target, 0.5)
|
||||||
assert_image_similar(im, target_img, 0.5)
|
|
||||||
|
|
||||||
ttf = ImageFont.truetype("Tests/fonts/KhmerOSBattambang-Regular.ttf", FONT_SIZE)
|
ttf = ImageFont.truetype("Tests/fonts/KhmerOSBattambang-Regular.ttf", FONT_SIZE)
|
||||||
|
|
||||||
|
@ -65,8 +62,7 @@ def test_complex_unicode_text():
|
||||||
draw.text((0, 0), "លោកុប្បត្តិ", font=ttf, fill=500)
|
draw.text((0, 0), "លោកុប្បត្តិ", font=ttf, fill=500)
|
||||||
|
|
||||||
target = "Tests/images/test_complex_unicode_text2.png"
|
target = "Tests/images/test_complex_unicode_text2.png"
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(im, target, 2.33)
|
||||||
assert_image_similar(im, target_img, 2.33)
|
|
||||||
|
|
||||||
|
|
||||||
def test_text_direction_rtl():
|
def test_text_direction_rtl():
|
||||||
|
@ -77,8 +73,7 @@ def test_text_direction_rtl():
|
||||||
draw.text((0, 0), "English عربي", font=ttf, fill=500, direction="rtl")
|
draw.text((0, 0), "English عربي", font=ttf, fill=500, direction="rtl")
|
||||||
|
|
||||||
target = "Tests/images/test_direction_rtl.png"
|
target = "Tests/images/test_direction_rtl.png"
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(im, target, 0.5)
|
||||||
assert_image_similar(im, target_img, 0.5)
|
|
||||||
|
|
||||||
|
|
||||||
def test_text_direction_ltr():
|
def test_text_direction_ltr():
|
||||||
|
@ -89,8 +84,7 @@ def test_text_direction_ltr():
|
||||||
draw.text((0, 0), "سلطنة عمان Oman", font=ttf, fill=500, direction="ltr")
|
draw.text((0, 0), "سلطنة عمان Oman", font=ttf, fill=500, direction="ltr")
|
||||||
|
|
||||||
target = "Tests/images/test_direction_ltr.png"
|
target = "Tests/images/test_direction_ltr.png"
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(im, target, 0.5)
|
||||||
assert_image_similar(im, target_img, 0.5)
|
|
||||||
|
|
||||||
|
|
||||||
def test_text_direction_rtl2():
|
def test_text_direction_rtl2():
|
||||||
|
@ -101,8 +95,7 @@ def test_text_direction_rtl2():
|
||||||
draw.text((0, 0), "Oman سلطنة عمان", font=ttf, fill=500, direction="rtl")
|
draw.text((0, 0), "Oman سلطنة عمان", font=ttf, fill=500, direction="rtl")
|
||||||
|
|
||||||
target = "Tests/images/test_direction_ltr.png"
|
target = "Tests/images/test_direction_ltr.png"
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(im, target, 0.5)
|
||||||
assert_image_similar(im, target_img, 0.5)
|
|
||||||
|
|
||||||
|
|
||||||
def test_text_direction_ttb():
|
def test_text_direction_ttb():
|
||||||
|
@ -117,8 +110,7 @@ def test_text_direction_ttb():
|
||||||
pytest.skip("libraqm 0.7 or greater not available")
|
pytest.skip("libraqm 0.7 or greater not available")
|
||||||
|
|
||||||
target = "Tests/images/test_direction_ttb.png"
|
target = "Tests/images/test_direction_ttb.png"
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(im, target, 2.8)
|
||||||
assert_image_similar(im, target_img, 2.8)
|
|
||||||
|
|
||||||
|
|
||||||
def test_text_direction_ttb_stroke():
|
def test_text_direction_ttb_stroke():
|
||||||
|
@ -141,8 +133,7 @@ def test_text_direction_ttb_stroke():
|
||||||
pytest.skip("libraqm 0.7 or greater not available")
|
pytest.skip("libraqm 0.7 or greater not available")
|
||||||
|
|
||||||
target = "Tests/images/test_direction_ttb_stroke.png"
|
target = "Tests/images/test_direction_ttb_stroke.png"
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(im, target, 19.4)
|
||||||
assert_image_similar(im, target_img, 19.4)
|
|
||||||
|
|
||||||
|
|
||||||
def test_ligature_features():
|
def test_ligature_features():
|
||||||
|
@ -152,8 +143,7 @@ def test_ligature_features():
|
||||||
draw = ImageDraw.Draw(im)
|
draw = ImageDraw.Draw(im)
|
||||||
draw.text((0, 0), "filling", font=ttf, fill=500, features=["-liga"])
|
draw.text((0, 0), "filling", font=ttf, fill=500, features=["-liga"])
|
||||||
target = "Tests/images/test_ligature_features.png"
|
target = "Tests/images/test_ligature_features.png"
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(im, target, 0.5)
|
||||||
assert_image_similar(im, target_img, 0.5)
|
|
||||||
|
|
||||||
liga_size = ttf.getsize("fi", features=["-liga"])
|
liga_size = ttf.getsize("fi", features=["-liga"])
|
||||||
assert liga_size == (13, 19)
|
assert liga_size == (13, 19)
|
||||||
|
@ -167,8 +157,7 @@ def test_kerning_features():
|
||||||
draw.text((0, 0), "TeToAV", font=ttf, fill=500, features=["-kern"])
|
draw.text((0, 0), "TeToAV", font=ttf, fill=500, features=["-kern"])
|
||||||
|
|
||||||
target = "Tests/images/test_kerning_features.png"
|
target = "Tests/images/test_kerning_features.png"
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(im, target, 0.5)
|
||||||
assert_image_similar(im, target_img, 0.5)
|
|
||||||
|
|
||||||
|
|
||||||
def test_arabictext_features():
|
def test_arabictext_features():
|
||||||
|
@ -185,8 +174,7 @@ def test_arabictext_features():
|
||||||
)
|
)
|
||||||
|
|
||||||
target = "Tests/images/test_arabictext_features.png"
|
target = "Tests/images/test_arabictext_features.png"
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(im, target, 0.5)
|
||||||
assert_image_similar(im, target_img, 0.5)
|
|
||||||
|
|
||||||
|
|
||||||
def test_x_max_and_y_offset():
|
def test_x_max_and_y_offset():
|
||||||
|
@ -197,8 +185,7 @@ def test_x_max_and_y_offset():
|
||||||
draw.text((0, 0), "لح", font=ttf, fill=500)
|
draw.text((0, 0), "لح", font=ttf, fill=500)
|
||||||
|
|
||||||
target = "Tests/images/test_x_max_and_y_offset.png"
|
target = "Tests/images/test_x_max_and_y_offset.png"
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(im, target, 0.5)
|
||||||
assert_image_similar(im, target_img, 0.5)
|
|
||||||
|
|
||||||
|
|
||||||
def test_language():
|
def test_language():
|
||||||
|
@ -209,8 +196,7 @@ def test_language():
|
||||||
draw.text((0, 0), "абвг", font=ttf, fill=500, language="sr")
|
draw.text((0, 0), "абвг", font=ttf, fill=500, language="sr")
|
||||||
|
|
||||||
target = "Tests/images/test_language.png"
|
target = "Tests/images/test_language.png"
|
||||||
with Image.open(target) as target_img:
|
assert_image_similar_tofile(im, target, 0.5)
|
||||||
assert_image_similar(im, target_img, 0.5)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("mode", ("L", "1"))
|
@pytest.mark.parametrize("mode", ("L", "1"))
|
||||||
|
@ -287,8 +273,7 @@ def test_anchor_ttb(anchor):
|
||||||
if str(ex) == "libraqm 0.7 or greater required for 'ttb' direction":
|
if str(ex) == "libraqm 0.7 or greater required for 'ttb' direction":
|
||||||
pytest.skip("libraqm 0.7 or greater not available")
|
pytest.skip("libraqm 0.7 or greater not available")
|
||||||
|
|
||||||
with Image.open(path) as expected:
|
assert_image_similar_tofile(im, path, 1) # fails at 5
|
||||||
assert_image_similar(im, expected, 1) # fails at 5
|
|
||||||
|
|
||||||
|
|
||||||
combine_tests = (
|
combine_tests = (
|
||||||
|
@ -351,8 +336,7 @@ def test_combine(name, text, dir, anchor, epsilon):
|
||||||
if str(ex) == "libraqm 0.7 or greater required for 'ttb' direction":
|
if str(ex) == "libraqm 0.7 or greater required for 'ttb' direction":
|
||||||
pytest.skip("libraqm 0.7 or greater not available")
|
pytest.skip("libraqm 0.7 or greater not available")
|
||||||
|
|
||||||
with Image.open(path) as expected:
|
assert_image_similar_tofile(im, path, epsilon)
|
||||||
assert_image_similar(im, expected, epsilon)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
@ -384,8 +368,7 @@ def test_combine_multiline(anchor, align):
|
||||||
d.rectangle(bbox, outline="red")
|
d.rectangle(bbox, outline="red")
|
||||||
d.multiline_text((200, 200), text, fill="black", anchor=anchor, font=f, align=align)
|
d.multiline_text((200, 200), text, fill="black", anchor=anchor, font=f, align=align)
|
||||||
|
|
||||||
with Image.open(path) as expected:
|
assert_image_similar_tofile(im, path, 0.015)
|
||||||
assert_image_similar(im, expected, 0.015)
|
|
||||||
|
|
||||||
|
|
||||||
def test_anchor_invalid_ttb():
|
def test_anchor_invalid_ttb():
|
||||||
|
|
|
@ -5,6 +5,7 @@ from PIL import Image, ImageDraw, ImageOps, ImageStat, features
|
||||||
from .helper import (
|
from .helper import (
|
||||||
assert_image_equal,
|
assert_image_equal,
|
||||||
assert_image_similar,
|
assert_image_similar,
|
||||||
|
assert_image_similar_tofile,
|
||||||
assert_tuple_approx_equal,
|
assert_tuple_approx_equal,
|
||||||
hopper,
|
hopper,
|
||||||
)
|
)
|
||||||
|
@ -112,10 +113,9 @@ def test_pad():
|
||||||
new_im = ImageOps.pad(im, new_size, color=color, centering=centering)
|
new_im = ImageOps.pad(im, new_size, color=color, centering=centering)
|
||||||
assert new_im.size == new_size
|
assert new_im.size == new_size
|
||||||
|
|
||||||
with Image.open(
|
assert_image_similar_tofile(
|
||||||
"Tests/images/imageops_pad_" + label + "_" + str(i) + ".jpg"
|
new_im, "Tests/images/imageops_pad_" + label + "_" + str(i) + ".jpg", 6
|
||||||
) as target:
|
)
|
||||||
assert_image_similar(new_im, target, 6)
|
|
||||||
|
|
||||||
|
|
||||||
def test_pil163():
|
def test_pil163():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user