-
Notifications
You must be signed in to change notification settings - Fork 13
0.3.0: pytest fails in all units with cannot identify image file
#168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Here is pytest output:+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pixelmatch-0.3.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pixelmatch-0.3.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.18, pytest-8.0.0, pluggy-1.3.0
benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0
plugins: benchmark-4.0.0
collected 30 items
test_pixelmatch.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [100%]
========================================================================================= FAILURES ==========================================================================================
_________________________________________________________________________ test_pixelmatch[1a-1b-1diff-options0-143] _________________________________________________________________________
img_path_1 = '1a', img_path_2 = '1b', diff_path = '1diff', options = {'threshold': 0.05}, expected_mismatch = 143
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f6569ddb5b0>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:68:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
_______________________________________________________________________ test_pixelmatch[1a-1b-1diffmask-options1-143] _______________________________________________________________________
img_path_1 = '1a', img_path_2 = '1b', diff_path = '1diffmask', options = {'diff_mask': True, 'includeAA': False, 'threshold': 0.05}, expected_mismatch = 143
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f6569371700>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:68:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
_____________________________________________________________________ test_pixelmatch[1a-1a-1emptydiffmask-options2-0] ______________________________________________________________________
img_path_1 = '1a', img_path_2 = '1a', diff_path = '1emptydiffmask', options = {'diff_mask': True, 'threshold': 0}, expected_mismatch = 0
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f656995c0a0>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:68:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
________________________________________________________________________ test_pixelmatch[2a-2b-2diff-options3-12437] ________________________________________________________________________
img_path_1 = '2a', img_path_2 = '2b', diff_path = '2diff', options = {'aa_color': [0, 192, 0], 'alpha': 0.5, 'diff_color': [255, 0, 255], 'threshold': 0.05}, expected_mismatch = 12437
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f6569371280>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:68:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/2a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/2a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
_________________________________________________________________________ test_pixelmatch[3a-3b-3diff-options4-212] _________________________________________________________________________
img_path_1 = '3a', img_path_2 = '3b', diff_path = '3diff', options = {'threshold': 0.05}, expected_mismatch = 212
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f6569ddb700>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:68:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/3a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/3a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
________________________________________________________________________ test_pixelmatch[4a-4b-4diff-options5-36049] ________________________________________________________________________
img_path_1 = '4a', img_path_2 = '4b', diff_path = '4diff', options = {'threshold': 0.05}, expected_mismatch = 36049
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f656970f910>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:68:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/4a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/4a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
__________________________________________________________________________ test_pixelmatch[5a-5b-5diff-options6-0] __________________________________________________________________________
img_path_1 = '5a', img_path_2 = '5b', diff_path = '5diff', options = {'threshold': 0.05}, expected_mismatch = 0
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f6569813700>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:68:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/5a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/5a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
_________________________________________________________________________ test_pixelmatch[6a-6b-6diff-options7-51] __________________________________________________________________________
img_path_1 = '6a', img_path_2 = '6b', diff_path = '6diff', options = {'threshold': 0.05}, expected_mismatch = 51
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f656965ec40>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:68:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/6a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/6a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
_________________________________________________________________________ test_pixelmatch[6a-6a-6empty-options8-0] __________________________________________________________________________
img_path_1 = '6a', img_path_2 = '6a', diff_path = '6empty', options = {'threshold': 0}, expected_mismatch = 0
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f656970f640>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:68:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/6a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/6a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
________________________________________________________________________ test_pixelmatch[7a-7b-7diff-options9-9856] _________________________________________________________________________
img_path_1 = '7a', img_path_2 = '7b', diff_path = '7diff', options = {'threshold': 0.05}, expected_mismatch = 9856
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f6569371580>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:68:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/7a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/7a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
____________________________________________________________________ test_pixelmatch_failfast[1a-1b-1diff-options0-143] _____________________________________________________________________
img_path_1 = '1a', img_path_2 = '1b', diff_path = '1diff', options = {'threshold': 0.05}, expected_mismatch = 143
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f65699f0d00>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch_failfast(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:97:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
__________________________________________________________________ test_pixelmatch_failfast[1a-1b-1diffmask-options1-143] ___________________________________________________________________
img_path_1 = '1a', img_path_2 = '1b', diff_path = '1diffmask', options = {'diff_mask': True, 'includeAA': False, 'threshold': 0.05}, expected_mismatch = 143
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f65694b1340>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch_failfast(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:97:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
_________________________________________________________________ test_pixelmatch_failfast[1a-1a-1emptydiffmask-options2-0] _________________________________________________________________
img_path_1 = '1a', img_path_2 = '1a', diff_path = '1emptydiffmask', options = {'diff_mask': True, 'threshold': 0}, expected_mismatch = 0
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f65699c9b80>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch_failfast(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:97:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
___________________________________________________________________ test_pixelmatch_failfast[2a-2b-2diff-options3-12437] ____________________________________________________________________
img_path_1 = '2a', img_path_2 = '2b', diff_path = '2diff', options = {'aa_color': [0, 192, 0], 'alpha': 0.5, 'diff_color': [255, 0, 255], 'threshold': 0.05}, expected_mismatch = 12437
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f656994e9d0>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch_failfast(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:97:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/2a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/2a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
____________________________________________________________________ test_pixelmatch_failfast[3a-3b-3diff-options4-212] _____________________________________________________________________
img_path_1 = '3a', img_path_2 = '3b', diff_path = '3diff', options = {'threshold': 0.05}, expected_mismatch = 212
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f65696028e0>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch_failfast(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:97:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/3a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/3a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
___________________________________________________________________ test_pixelmatch_failfast[4a-4b-4diff-options5-36049] ____________________________________________________________________
img_path_1 = '4a', img_path_2 = '4b', diff_path = '4diff', options = {'threshold': 0.05}, expected_mismatch = 36049
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f65699f0670>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch_failfast(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:97:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/4a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/4a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
_____________________________________________________________________ test_pixelmatch_failfast[5a-5b-5diff-options6-0] ______________________________________________________________________
img_path_1 = '5a', img_path_2 = '5b', diff_path = '5diff', options = {'threshold': 0.05}, expected_mismatch = 0
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f656975daf0>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch_failfast(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:97:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/5a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/5a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
_____________________________________________________________________ test_pixelmatch_failfast[6a-6b-6diff-options7-51] _____________________________________________________________________
img_path_1 = '6a', img_path_2 = '6b', diff_path = '6diff', options = {'threshold': 0.05}, expected_mismatch = 51
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f65694b8940>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch_failfast(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:97:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/6a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/6a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
_____________________________________________________________________ test_pixelmatch_failfast[6a-6a-6empty-options8-0] _____________________________________________________________________
img_path_1 = '6a', img_path_2 = '6a', diff_path = '6empty', options = {'threshold': 0}, expected_mismatch = 0
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f65696be6a0>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch_failfast(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:97:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/6a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/6a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
____________________________________________________________________ test_pixelmatch_failfast[7a-7b-7diff-options9-9856] ____________________________________________________________________
img_path_1 = '7a', img_path_2 = '7b', diff_path = '7diff', options = {'threshold': 0.05}, expected_mismatch = 9856
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f6569337520>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_pixelmatch_failfast(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:97:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/7a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/7a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
_______________________________________________________________________ test_PIL_pixelmatch[1a-1b-1diff-options0-143] _______________________________________________________________________
img_path_1 = '1a', img_path_2 = '1b', diff_path = '1diff', options = {'threshold': 0.05}, expected_mismatch = 143
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f65694b8af0>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_PIL_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:128:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
_____________________________________________________________________ test_PIL_pixelmatch[1a-1b-1diffmask-options1-143] _____________________________________________________________________
img_path_1 = '1a', img_path_2 = '1b', diff_path = '1diffmask', options = {'diff_mask': True, 'includeAA': False, 'threshold': 0.05}, expected_mismatch = 143
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f65697a20d0>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_PIL_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:128:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
___________________________________________________________________ test_PIL_pixelmatch[1a-1a-1emptydiffmask-options2-0] ____________________________________________________________________
img_path_1 = '1a', img_path_2 = '1a', diff_path = '1emptydiffmask', options = {'diff_mask': True, 'threshold': 0}, expected_mismatch = 0
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f65696d0c10>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_PIL_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:128:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
______________________________________________________________________ test_PIL_pixelmatch[2a-2b-2diff-options3-12437] ______________________________________________________________________
img_path_1 = '2a', img_path_2 = '2b', diff_path = '2diff', options = {'aa_color': [0, 192, 0], 'alpha': 0.5, 'diff_color': [255, 0, 255], 'threshold': 0.05}, expected_mismatch = 12437
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f65697c4f10>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_PIL_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:128:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/2a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/2a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
_______________________________________________________________________ test_PIL_pixelmatch[3a-3b-3diff-options4-212] _______________________________________________________________________
img_path_1 = '3a', img_path_2 = '3b', diff_path = '3diff', options = {'threshold': 0.05}, expected_mismatch = 212
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f656970f8e0>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_PIL_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:128:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/3a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/3a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
______________________________________________________________________ test_PIL_pixelmatch[4a-4b-4diff-options5-36049] ______________________________________________________________________
img_path_1 = '4a', img_path_2 = '4b', diff_path = '4diff', options = {'threshold': 0.05}, expected_mismatch = 36049
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f6569602730>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_PIL_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:128:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/4a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/4a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
________________________________________________________________________ test_PIL_pixelmatch[5a-5b-5diff-options6-0] ________________________________________________________________________
img_path_1 = '5a', img_path_2 = '5b', diff_path = '5diff', options = {'threshold': 0.05}, expected_mismatch = 0
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f656965ea90>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_PIL_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:128:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/5a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/5a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
_______________________________________________________________________ test_PIL_pixelmatch[6a-6b-6diff-options7-51] ________________________________________________________________________
img_path_1 = '6a', img_path_2 = '6b', diff_path = '6diff', options = {'threshold': 0.05}, expected_mismatch = 51
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f65694b8fa0>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_PIL_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:128:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/6a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/6a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
_______________________________________________________________________ test_PIL_pixelmatch[6a-6a-6empty-options8-0] ________________________________________________________________________
img_path_1 = '6a', img_path_2 = '6a', diff_path = '6empty', options = {'threshold': 0}, expected_mismatch = 0
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f65694b1d30>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_PIL_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:128:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/6a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/6a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
______________________________________________________________________ test_PIL_pixelmatch[7a-7b-7diff-options9-9856] _______________________________________________________________________
img_path_1 = '7a', img_path_2 = '7b', diff_path = '7diff', options = {'threshold': 0.05}, expected_mismatch = 9856
benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f65698777f0>
@pytest.mark.parametrize(
"img_path_1,img_path_2,diff_path,options,expected_mismatch", testdata
)
def test_PIL_pixelmatch(
img_path_1: str,
img_path_2: str,
diff_path: str,
options: Dict,
expected_mismatch: int,
benchmark,
):
> img1 = read_img(img_path_1)
test_pixelmatch.py:128:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_pixelmatch.py:15: in read_img
return Image.open(FIXTURES_PATH / f"{name}.png")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fp = <_io.BufferedReader name='/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/7a.png'>, mode = 'r', formats = ['BMP', 'DIB', 'GIF', 'JPEG', 'PPM', 'PNG', ...]
def open(fp, mode="r", formats=None) -> Image:
"""
Opens and identifies the given image file.
This is a lazy operation; this function identifies the file, but
the file remains open and the actual image data is not read from
the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement ``file.read``,
``file.seek``, and ``file.tell`` methods,
and be opened in binary mode. The file object will also seek to zero
before reading.
:param mode: The mode. If given, this argument must be "r".
:param formats: A list or tuple of formats to attempt to load the file in.
This can be used to restrict the set of formats checked.
Pass ``None`` to try all supported formats. You can print the set of
available formats by running ``python3 -m PIL`` or using
the :py:func:`PIL.features.pilinfo` function.
:returns: An :py:class:`~PIL.Image.Image` object.
:exception FileNotFoundError: If the file cannot be found.
:exception PIL.UnidentifiedImageError: If the image cannot be opened and
identified.
:exception ValueError: If the ``mode`` is not "r", or if a ``StringIO``
instance is used for ``fp``.
:exception TypeError: If ``formats`` is not ``None``, a list or a tuple.
"""
if mode != "r":
msg = f"bad mode {repr(mode)}"
raise ValueError(msg)
elif isinstance(fp, io.StringIO):
msg = (
"StringIO cannot be used to open an image. "
"Binary data must be used instead."
)
raise ValueError(msg)
if formats is None:
formats = ID
elif not isinstance(formats, (list, tuple)):
msg = "formats must be a list or tuple"
raise TypeError(msg)
exclusive_fp = False
filename = ""
if isinstance(fp, Path):
filename = str(fp.resolve())
elif is_path(fp):
filename = fp
if filename:
fp = builtins.open(filename, "rb")
exclusive_fp = True
try:
fp.seek(0)
except (AttributeError, io.UnsupportedOperation):
fp = io.BytesIO(fp.read())
exclusive_fp = True
prefix = fp.read(16)
preinit()
accept_warnings = []
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try:
factory, accept = OPEN[i]
result = not accept or accept(prefix)
if type(result) in [str, bytes]:
accept_warnings.append(result)
elif result:
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
# logger.debug("", exc_info=True)
continue
except BaseException:
if exclusive_fp:
fp.close()
raise
return None
im = _open_core(fp, filename, prefix, formats)
if im is None and formats is ID:
checked_formats = formats.copy()
if init():
im = _open_core(
fp,
filename,
prefix,
tuple(format for format in formats if format not in checked_formats),
)
if im:
im._exclusive_fp = exclusive_fp
return im
if exclusive_fp:
fp.close()
for message in accept_warnings:
warnings.warn(message)
msg = "cannot identify image file %r" % (filename if filename else fp)
> raise UnidentifiedImageError(msg)
E PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/7a.png'
/usr/lib64/python3.8/site-packages/PIL/Image.py:3309: UnidentifiedImageError
===================================================================================== warnings summary ======================================================================================
test_pixelmatch.py: 10 warnings
test_pixelmatch.py:56: PytestBenchmarkWarning: Benchmark fixture was not used at all in this test!
@pytest.mark.parametrize(
test_pixelmatch.py: 10 warnings
test_pixelmatch.py:86: PytestBenchmarkWarning: Benchmark fixture was not used at all in this test!
@pytest.mark.parametrize(
test_pixelmatch.py: 10 warnings
test_pixelmatch.py:117: PytestBenchmarkWarning: Benchmark fixture was not used at all in this test!
@pytest.mark.parametrize(
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================== short test summary info ==================================================================================
FAILED test_pixelmatch.py::test_pixelmatch[1a-1b-1diff-options0-143] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'
FAILED test_pixelmatch.py::test_pixelmatch[1a-1b-1diffmask-options1-143] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'
FAILED test_pixelmatch.py::test_pixelmatch[1a-1a-1emptydiffmask-options2-0] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'
FAILED test_pixelmatch.py::test_pixelmatch[2a-2b-2diff-options3-12437] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/2a.png'
FAILED test_pixelmatch.py::test_pixelmatch[3a-3b-3diff-options4-212] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/3a.png'
FAILED test_pixelmatch.py::test_pixelmatch[4a-4b-4diff-options5-36049] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/4a.png'
FAILED test_pixelmatch.py::test_pixelmatch[5a-5b-5diff-options6-0] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/5a.png'
FAILED test_pixelmatch.py::test_pixelmatch[6a-6b-6diff-options7-51] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/6a.png'
FAILED test_pixelmatch.py::test_pixelmatch[6a-6a-6empty-options8-0] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/6a.png'
FAILED test_pixelmatch.py::test_pixelmatch[7a-7b-7diff-options9-9856] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/7a.png'
FAILED test_pixelmatch.py::test_pixelmatch_failfast[1a-1b-1diff-options0-143] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'
FAILED test_pixelmatch.py::test_pixelmatch_failfast[1a-1b-1diffmask-options1-143] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'
FAILED test_pixelmatch.py::test_pixelmatch_failfast[1a-1a-1emptydiffmask-options2-0] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'
FAILED test_pixelmatch.py::test_pixelmatch_failfast[2a-2b-2diff-options3-12437] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/2a.png'
FAILED test_pixelmatch.py::test_pixelmatch_failfast[3a-3b-3diff-options4-212] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/3a.png'
FAILED test_pixelmatch.py::test_pixelmatch_failfast[4a-4b-4diff-options5-36049] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/4a.png'
FAILED test_pixelmatch.py::test_pixelmatch_failfast[5a-5b-5diff-options6-0] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/5a.png'
FAILED test_pixelmatch.py::test_pixelmatch_failfast[6a-6b-6diff-options7-51] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/6a.png'
FAILED test_pixelmatch.py::test_pixelmatch_failfast[6a-6a-6empty-options8-0] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/6a.png'
FAILED test_pixelmatch.py::test_pixelmatch_failfast[7a-7b-7diff-options9-9856] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/7a.png'
FAILED test_pixelmatch.py::test_PIL_pixelmatch[1a-1b-1diff-options0-143] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'
FAILED test_pixelmatch.py::test_PIL_pixelmatch[1a-1b-1diffmask-options1-143] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'
FAILED test_pixelmatch.py::test_PIL_pixelmatch[1a-1a-1emptydiffmask-options2-0] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/1a.png'
FAILED test_pixelmatch.py::test_PIL_pixelmatch[2a-2b-2diff-options3-12437] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/2a.png'
FAILED test_pixelmatch.py::test_PIL_pixelmatch[3a-3b-3diff-options4-212] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/3a.png'
FAILED test_pixelmatch.py::test_PIL_pixelmatch[4a-4b-4diff-options5-36049] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/4a.png'
FAILED test_pixelmatch.py::test_PIL_pixelmatch[5a-5b-5diff-options6-0] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/5a.png'
FAILED test_pixelmatch.py::test_PIL_pixelmatch[6a-6b-6diff-options7-51] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/6a.png'
FAILED test_pixelmatch.py::test_PIL_pixelmatch[6a-6a-6empty-options8-0] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/6a.png'
FAILED test_pixelmatch.py::test_PIL_pixelmatch[7a-7b-7diff-options9-9856] - PIL.UnidentifiedImageError: cannot identify image file '/home/tkloczko/rpmbuild/BUILD/pixelmatch-py-0.3.0/fixtures/7a.png'
============================================================================== 30 failed, 30 warnings in 2.02s ============================================================================== |
Hmm looks like all those png files are text files 🤔 [tkloczko@pers-jacek pixelmatch-py-0.3.0]$ file fixtures/*.png
fixtures/1a.png: ASCII text
fixtures/1b.png: ASCII text
fixtures/1diff.png: ASCII text
fixtures/1diffmask.png: ASCII text
fixtures/1emptydiffmask.png: ASCII text
fixtures/2a.png: ASCII text
fixtures/2b.png: ASCII text
fixtures/2diff.png: ASCII text
fixtures/3a.png: ASCII text
fixtures/3b.png: ASCII text
fixtures/3diff.png: ASCII text
fixtures/4a.png: ASCII text
fixtures/4b.png: ASCII text
fixtures/4diff.png: ASCII text
fixtures/5a.png: ASCII text
fixtures/5b.png: ASCII text
fixtures/5diff.png: ASCII text
fixtures/6a.png: ASCII text
fixtures/6b.png: ASCII text
fixtures/6diff.png: ASCII text
fixtures/6empty.png: ASCII text
fixtures/7a.png: ASCII text
fixtures/7b.png: ASCII text
fixtures/7diff.png: ASCII text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.
python3 -sBm build -w --no-isolation
build
with--no-isolation
I'm using during all processes only locally installed modulescut off from access to the public network
(pytest is executed with-m "not network"
)List of installed modules in build env:
Please let me know if you need more details or want me to perform some diagnostics.
The text was updated successfully, but these errors were encountered: