@@ -164,13 +164,16 @@ def test_3050():
164164 This is known to fail if MuPDF is built without it's default third-party
165165 libraries, e.g. in Linux system installs.
166166 '''
167- pdf_file = pymupdf .open (pdf )
168- for page_no , page in enumerate (pdf_file ):
167+ path = os .path .normpath (f'{ __file__ } /../../tests/resources/001003ED.pdf' )
168+ with pymupdf .open (path ) as pdf_file :
169+ page_no = 0
170+ page = pdf_file [page_no ]
169171 zoom_x = 4.0
170172 zoom_y = 4.0
171173 matrix = pymupdf .Matrix (zoom_x , zoom_y )
172174 pix = page .get_pixmap (matrix = matrix )
173- digest0 = pix .digest
175+ path_out = os .path .normpath (f'{ __file__ } /../../tests/test_3050_out.png' )
176+ pix .save (path_out )
174177 print (f'{ pix .width = } { pix .height = } ' )
175178 def product (x , y ):
176179 for yy in y :
@@ -183,16 +186,18 @@ def product(x, y):
183186 if sum (pix .pixel (pos [0 ], pos [1 ])) >= 600 :
184187 n += 1
185188 pix .set_pixel (pos [0 ], pos [1 ], (255 , 255 , 255 ))
186- digest1 = pix .digest
187- print (f'{ page_no = } { n = } { digest0 = } { digest1 = } ' )
188- digest_expected = b'\xd7 x\x94 _\x98 \xa1 <-/\xf3 \xf9 \x04 \xec #\xaa \xee '
189- pix .save (os .path .abspath (f'{ __file__ } /../../tests/test_3050_out.png' ))
190- assert digest1 != digest0
191- assert digest1 == digest_expected
192- rebased = hasattr (pymupdf , 'mupdf' )
193- if rebased :
194- wt = pymupdf .TOOLS .mupdf_warnings ()
195- assert wt == 'PDF stream Length incorrect'
189+ path_out2 = os .path .normpath (f'{ __file__ } /../../tests/test_3050_out2.png' )
190+ pix .save (path_out2 )
191+ path_expected = os .path .normpath (f'{ __file__ } /../../tests/resources/test_3050_expected.png' )
192+ rms = gentle_compare .pixmaps_rms (path_expected , path_out2 )
193+ print (f'{ rms = } ' )
194+ if pymupdf .mupdf_version_tuple < (1 , 26 ):
195+ # Slight differences in rendering from fix for mupdf bug 708274.
196+ assert rms < 0.2
197+ else :
198+ assert rms == 0
199+ wt = pymupdf .TOOLS .mupdf_warnings ()
200+ assert wt == 'PDF stream Length incorrect'
196201
197202def test_3058 ():
198203 doc = pymupdf .Document (os .path .abspath (f'{ __file__ } /../../tests/resources/test_3058.pdf' ))
0 commit comments