1

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

user1130176
  • 1,772
  • 1
  • 23
  • 33
  • Generally, no. But if the image is text, then one can often use FFT processing to determine the rotation angle. For example I have a bash unix shell script that does that called textdeskew. It find the rotation angle using FFT processing and then uses -rotate or -distort SRT to deskew. – fmw42 Mar 09 '22 at 17:50
  • would you please share the script? – user1130176 Mar 09 '22 at 19:13

1 Answers1

2

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

fmw42
  • 46,825
  • 10
  • 62
  • 80