Fix tesseract_noop.py generating wrong size of output PDF in tests
This caused trouble before with test_deskew
This commit is contained in:
@@ -73,10 +73,11 @@ def main():
|
||||
output = sys.argv[-3]
|
||||
with Image.open(inputf) as im:
|
||||
dpi = im.info['dpi']
|
||||
imsize = im.size[0] * dpi[0] / 72, im.size[1] * dpi[1] / 72
|
||||
pagesize = im.size[0] / dpi[0], im.size[1] / dpi[1]
|
||||
ptsize = pagesize[0] * 72, pagesize[1] * 72
|
||||
|
||||
pdf_out = pypdf.PdfFileWriter()
|
||||
pdf_out.addBlankPage(imsize[0], imsize[1])
|
||||
pdf_out.addBlankPage(ptsize[0], ptsize[1])
|
||||
with open(output + '.pdf', 'wb') as f:
|
||||
pdf_out.write(f)
|
||||
with open(output + '.txt', 'w') as f:
|
||||
|
||||
+5
-5
@@ -71,11 +71,10 @@ def test_quick(spoof_tesseract_cache, resources, outpdf):
|
||||
check_ocrmypdf(resources / 'ccitt.pdf', outpdf, env=spoof_tesseract_cache)
|
||||
|
||||
|
||||
@pytest.mark.filterwarnings('ignore:Image size')
|
||||
def test_deskew(spoof_tesseract_noop, resources, outdir):
|
||||
# Run with deskew
|
||||
deskewed_pdf = check_ocrmypdf(
|
||||
resources / 'skew.pdf', outdir / 'skew.pdf', '-d', '-v', '1',
|
||||
resources / 'skew.pdf', outdir / 'skew.pdf', '-d',
|
||||
env=spoof_tesseract_noop)
|
||||
|
||||
# Now render as an image again and use Leptonica to find the skew angle
|
||||
@@ -90,7 +89,8 @@ def test_deskew(spoof_tesseract_noop, resources, outdir):
|
||||
xres=150,
|
||||
yres=150,
|
||||
raster_device='pngmono',
|
||||
log=log)
|
||||
log=log,
|
||||
pageno=1)
|
||||
|
||||
from ocrmypdf.leptonica import Pix
|
||||
pix = Pix.read(str(deskewed_png))
|
||||
@@ -129,8 +129,8 @@ def test_remove_background(spoof_tesseract_noop, resources, outdir):
|
||||
xres=100,
|
||||
yres=100,
|
||||
raster_device='png16m',
|
||||
log=log)
|
||||
|
||||
log=log,
|
||||
pageno=1)
|
||||
|
||||
# The output image should contain pure white and black
|
||||
im = Image.open(output_png)
|
||||
|
||||
Reference in New Issue
Block a user