Skip to content

Commit 88f8410

Browse files
committed
test for OpenCV bug #89
Signed-off-by: Alexander Piskun <[email protected]>
1 parent 4b85204 commit 88f8410

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

tests/opencv_bug.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# https://github.com/bigcat88/pillow_heif/issues/89
2+
3+
from io import BytesIO
4+
5+
import cv2 # noqa
6+
from PIL import Image
7+
8+
from pillow_heif import from_pillow, libheif_info
9+
10+
print(libheif_info())
11+
from_pillow(Image.linear_gradient(mode="L")).save(BytesIO(), format="HEIF")

tests/opencv_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# With OpenCV, we test BGR, BGRA, BGR;16 and BGRA;16 modes
22

33
import os
4+
import sys
45
from io import BytesIO
56
from pathlib import Path
7+
from subprocess import CalledProcessError, run
68

79
import pytest
810
from helpers import compare_hashes, hevc_enc
@@ -145,3 +147,13 @@ def test_read_8_10_12_bit(img):
145147
path_to_png = path_to_png.replace("_10_", "_16_")
146148
path_to_png = path_to_png.replace("_12_", "_16_")
147149
compare_hashes([BytesIO(img_encode), path_to_png], hash_size=16)
150+
151+
152+
def test_opencv_crash():
153+
# https://github.com/bigcat88/pillow_heif/issues/89
154+
path_to_test_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "opencv_bug.py")
155+
if sys.platform.lower() == "darwin":
156+
with pytest.raises(CalledProcessError):
157+
run([sys.executable, path_to_test_file], check=True)
158+
else:
159+
run([sys.executable, path_to_test_file], check=True)

0 commit comments

Comments
 (0)