MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / test_3050

Function test_3050

tests/test_pixmap.py:166–203  ·  view source on GitHub ↗

This is known to fail if MuPDF is built without it's default third-party libraries, e.g. in Linux system installs.

()

Source from the content-addressed store, hash-verified

164 pm4 = pymupdf.Pixmap(pm, pm3)
165
166def test_3050():
167 '''
168 This is known to fail if MuPDF is built without it's default third-party
169 libraries, e.g. in Linux system installs.
170 '''
171 path = os.path.normpath(f'{__file__}/../../tests/resources/001003ED.pdf')
172 with pymupdf.open(path) as pdf_file:
173 page_no = 0
174 page = pdf_file[page_no]
175 zoom_x = 4.0
176 zoom_y = 4.0
177 matrix = pymupdf.Matrix(zoom_x, zoom_y)
178 pix = page.get_pixmap(matrix=matrix)
179 path_out = os.path.normpath(f'{__file__}/../../tests/test_3050_out.png')
180 pix.save(path_out)
181 print(f'{pix.width=} {pix.height=}')
182 def product(x, y):
183 for yy in y:
184 for xx in x:
185 yield (xx, yy)
186 n = 0
187 # We use a small subset of the image because non-optimised build gets
188 # very slow.
189 for pos in product(range(100), range(100)):
190 if sum(pix.pixel(pos[0], pos[1])) >= 600:
191 n += 1
192 pix.set_pixel(pos[0], pos[1], (255, 255, 255))
193 path_out2 = os.path.normpath(f'{__file__}/../../tests/test_3050_out2.png')
194 pix.save(path_out2)
195 path_expected = os.path.normpath(f'{__file__}/../../tests/resources/test_3050_expected.png')
196 rms = gentle_compare.pixmaps_rms(path_expected, path_out2)
197 print(f'{rms=}')
198 assert rms == 0
199 wt = pymupdf.TOOLS.mupdf_warnings()
200 if (1, 26, 0) <= pymupdf.mupdf_version_tuple < (1, 27):
201 assert wt == 'bogus font ascent/descent values (0 / 0)\nPDF stream Length incorrect'
202 else:
203 assert wt == 'PDF stream Length incorrect'
204
205def test_3058():
206 doc = pymupdf.Document(os.path.abspath(f'{__file__}/../../tests/resources/test_3058.pdf'))

Callers

nothing calls this directly

Calls 6

productFunction · 0.85
pixelMethod · 0.80
set_pixelMethod · 0.80
mupdf_warningsMethod · 0.80
get_pixmapMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…