diff --git a/src/ocrmypdf/leptonica.py b/src/ocrmypdf/leptonica.py index e8e9c988..50fdb3b1 100644 --- a/src/ocrmypdf/leptonica.py +++ b/src/ocrmypdf/leptonica.py @@ -132,7 +132,7 @@ class Pix: This class treats Pix objects as immutable. All methods return new modified objects. This allows convenient chaining: - >>> Pix.read('filename.jpg').scale((0.5, 0.5)).deskew().show() + >>> Pix.open('filename.jpg').scale((0.5, 0.5)).deskew().show() """ @@ -593,7 +593,7 @@ def get_leptonica_version(): def deskew(infile, outfile, dpi): try: - pix_source = Pix.read(infile) + pix_source = Pix.open(infile) except LeptonicaIOError: raise LeptonicaIOError("Failed to open file: %s" % infile) @@ -612,7 +612,7 @@ def deskew(infile, outfile, dpi): def remove_background(infile, outfile, tile_size=(40, 60), gamma=1.0, black_threshold=70, white_threshold=190): try: - pix = Pix.read(infile) + pix = Pix.open(infile) except LeptonicaIOError: raise LeptonicaIOError("Failed to open file: %s" % infile) diff --git a/tests/test_lept.py b/tests/test_lept.py index be68ea98..6fd0a486 100644 --- a/tests/test_lept.py +++ b/tests/test_lept.py @@ -26,5 +26,5 @@ import ocrmypdf.leptonica as lept def test_colormap_backgroundnorm(resources): # Issue #262 - unclear how to reproduce exactly, so just ensure leptonica # can handle that case - pix = lept.Pix.read(resources / 'baiona-colormapped.png') + pix = lept.Pix.open(resources / 'baiona-colormapped.png') pix.background_norm() diff --git a/tests/test_main.py b/tests/test_main.py index 464d8d2b..e72dc102 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -109,7 +109,7 @@ def test_deskew(spoof_tesseract_noop, resources, outdir): log=log, pageno=1) - pix = Pix.read(str(deskewed_png)) + pix = Pix.open(deskewed_png) skew_angle, skew_confidence = pix.find_skew() print(skew_angle)