diff --git a/src/__init__.py b/src/__init__.py index 006889a21..76975d1ee 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -17088,8 +17088,12 @@ def JM_read_contents(pageref): def JM_rect_from_py(r): if isinstance(r, mupdf.FzRect): return r + if isinstance(r, mupdf.FzIrect): + return mupdf.FzRect(r) if isinstance(r, Rect): return mupdf.fz_make_rect(r.x0, r.y0, r.x1, r.y1) + if isinstance(r, IRect): + return mupdf.fz_make_rect(r.x0, r.y0, r.x1, r.y1) if not r or not PySequence_Check(r) or PySequence_Size(r) != 4: return mupdf.FzRect(mupdf.FzRect.Fixed_INFINITE) f = [0, 0, 0, 0] diff --git a/tests/test_pixmap.py b/tests/test_pixmap.py index 3c4a1be5d..f2615158f 100644 --- a/tests/test_pixmap.py +++ b/tests/test_pixmap.py @@ -233,3 +233,15 @@ def test_3072(): pix = page_49.get_pixmap(clip=rect, matrix=zoom) image_save_path = f'{out}/2.jpg' pix.save(image_save_path, jpg_quality=95) + +def test_3134(): + doc = fitz.Document() + page = doc.new_page() + page.get_pixmap(clip=fitz.Rect(0, 0, 100, 100)).save("test_3134_rect.jpg") + page.get_pixmap(clip=fitz.IRect(0, 0, 100, 100)).save("test_3134_irect.jpg") + stat_rect = os.stat('test_3134_rect.jpg') + stat_irect = os.stat('test_3134_irect.jpg') + print(f' {stat_rect=}') + print(f'{stat_irect=}') + assert stat_rect.st_size == stat_irect.st_size +