Search code examples
imagemagick

Detect skewed image with imagemagick


I previously posted how to auto fix a skewed image, is there a way to simply detect that it is skewed with image magick? I.e. is there a command that I could run on two images, one skewed and one not, and use that output as the determinant of whether it's skewed?

Thanks for any help, Kevin


Solution

  • Correction to my comment above. There is a way to determine the skew angle in Imagemagick if you have regular lines of text.

    Input:

    enter image description here

    convert img.jpg -deskew 60% -format "%[deskew:angle]" info:
    
    2.18111
    

    See https://imagemagick.org/script/escape.php