Fix issue with attempting to deskew a blank page on Tesseract 5

Closes #868
This commit is contained in:
James R. Barlow
2021-12-10 21:48:09 -08:00
parent 1ec2ccca14
commit d48254d477
2 changed files with 8 additions and 1 deletions
+3 -1
View File
@@ -200,7 +200,9 @@ def get_deskew(
except CalledProcessError as e:
tesseract_log_output(e.stdout)
tesseract_log_output(e.stderr)
if b'Empty page!!' in e.output: # Not enough info for a skew angle
if b'Empty page!!' in e.output or (
e.output == b'' and e.returncode == 1
): # Not enough info for a skew angle - Tess 4 and 5 return different errors
return 0.0
raise SubprocessOutputError() from e
+5
View File
@@ -40,6 +40,11 @@ def test_deskew(resources, outdir):
assert -0.5 < skew_angle < 0.5, "Deskewing failed"
def test_deskew_blank_page(resources, outpdf):
# Tesseract doesn't like blank pages - make sure we can get through
check_ocrmypdf(resources / 'blank.pdf', outpdf, '--deskew')
@pytest.mark.xfail(reason="remove background disabled")
def test_remove_background(resources, outdir):
# Ensure the input image does not contain pure white/black