Python Wand auto rotate and deskew not working

112 Views Asked by At

I have a medical form page that is not properly oriented (it's rotated 90 degrees clockwise) and it has text skew. I want to use Wand methods to auto orient the page to be human legible, and also to de-skew the text. So far, I've tested and I think that de-skew works. Here comes the first question:

  1. I don't understand the threshold parameter in the de-skew method. What is the meaning of that "limit"? How can I parametrize that value to not be hardcoded?

  2. Auto orient method is not working at all. And it's not returning any value or log to know why.

This is the code that I'm using with the threshold hardcoded as 0.9 and attached is the sample file.

Anyone knows why auto_orient is not working?

    from wand.image import Image

        with Image(filename='dummy_edu_form.jpeg') as img:
        img.auto_orient()
        img.deskew(0.9*img.quantum_range)
        img.save(filename='wand_output.jpeg')

OS and library information:

  • Wand==0.6.11
  • Version: ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25 https://imagemagick.org
  • Python: 3.9.17
  • OS: Operating System: Linux Mint 21, Kernel: Linux 5.15.0-76-generic, Architecture: x86-64. This information should not be relevant because this code is intended to work in an AWS Lambda.

dummy_edu_form.jpeg

Edit: Also I add this picture taken as landscape. Result is the same. enter image description here

0

There are 0 best solutions below