Refactor xy-pair for resolution to tuple
This commit is contained in:
@@ -50,12 +50,7 @@ def test_deskew(spoof_tesseract_noop, resources, outdir):
|
||||
deskewed_png = outdir / 'deskewed.png'
|
||||
|
||||
ghostscript.rasterize_pdf(
|
||||
deskewed_pdf,
|
||||
deskewed_png,
|
||||
xres=150,
|
||||
yres=150,
|
||||
raster_device='pngmono',
|
||||
pageno=1,
|
||||
deskewed_pdf, deskewed_png, raster_device='pngmono', xyres=(150, 150), pageno=1
|
||||
)
|
||||
|
||||
pix = Pix.open(deskewed_png)
|
||||
@@ -82,7 +77,7 @@ def test_remove_background(spoof_tesseract_noop, resources, outdir):
|
||||
output_png = outdir / 'remove_bg.png'
|
||||
|
||||
ghostscript.rasterize_pdf(
|
||||
output_pdf, output_png, xres=100, yres=100, raster_device='png16m', pageno=1
|
||||
output_pdf, output_png, raster_device='png16m', xyres=(100, 100), pageno=1
|
||||
)
|
||||
|
||||
# The output image should contain pure white and black
|
||||
@@ -122,7 +117,7 @@ def test_exotic_image(
|
||||
def test_non_square_resolution(renderer, spoof_tesseract_cache, resources, outpdf):
|
||||
# Confirm input image is non-square resolution
|
||||
in_pageinfo = PdfInfo(resources / 'aspect.pdf')
|
||||
assert in_pageinfo[0].xres != in_pageinfo[0].yres
|
||||
assert in_pageinfo[0].xyres[0] != in_pageinfo[0].xyres[1]
|
||||
|
||||
check_ocrmypdf(
|
||||
resources / 'aspect.pdf',
|
||||
@@ -135,8 +130,7 @@ def test_non_square_resolution(renderer, spoof_tesseract_cache, resources, outpd
|
||||
out_pageinfo = PdfInfo(outpdf)
|
||||
|
||||
# Confirm resolution was kept the same
|
||||
assert in_pageinfo[0].xres == out_pageinfo[0].xres
|
||||
assert in_pageinfo[0].yres == out_pageinfo[0].yres
|
||||
assert in_pageinfo[0].xyres == out_pageinfo[0].xyres
|
||||
|
||||
|
||||
@pytest.mark.parametrize('renderer', RENDERERS)
|
||||
@@ -145,7 +139,7 @@ def test_convert_to_square_resolution(
|
||||
):
|
||||
# Confirm input image is non-square resolution
|
||||
in_pageinfo = PdfInfo(resources / 'aspect.pdf')
|
||||
assert in_pageinfo[0].xres != in_pageinfo[0].yres
|
||||
assert in_pageinfo[0].xyres[0] != in_pageinfo[0].xyres[1]
|
||||
|
||||
# --force-ocr requires means forced conversion to square resolution
|
||||
check_ocrmypdf(
|
||||
@@ -162,7 +156,7 @@ def test_convert_to_square_resolution(
|
||||
in_p0, out_p0 = in_pageinfo[0], out_pageinfo[0]
|
||||
|
||||
# Resolution show now be equal
|
||||
assert out_p0.xres == out_p0.yres
|
||||
assert out_p0.xyres[0] == out_p0.xyres[1]
|
||||
|
||||
# Page size should match input page size
|
||||
assert isclose(in_p0.width_inches, out_p0.width_inches)
|
||||
@@ -170,7 +164,7 @@ def test_convert_to_square_resolution(
|
||||
|
||||
# Because we rasterized the page to produce a new image, it should occupy
|
||||
# the entire page
|
||||
out_im_w = out_p0.images[0].width / out_p0.images[0].xres
|
||||
out_im_h = out_p0.images[0].height / out_p0.images[0].yres
|
||||
out_im_w = out_p0.images[0].width / out_p0.images[0].xyres[0]
|
||||
out_im_h = out_p0.images[0].height / out_p0.images[0].xyres[1]
|
||||
assert isclose(out_p0.width_inches, out_im_w)
|
||||
assert isclose(out_p0.height_inches, out_im_h)
|
||||
|
||||
Reference in New Issue
Block a user