Possible bug -deskew auto-crop IM 6.9.5.4 Q16 Mac OSX

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Possible bug -deskew auto-crop IM 6.9.5.4 Q16 Mac OSX

Post by fmw42 »

The documentation says:

-deskew threshold{%}
straighten an image. A threshold of 40% works for most images.

Use -set option:deskew:auto-crop width to auto crop the image. The set argument is the pixel width of the image background (e.g 40).


Perhaps I am confused about what the -set option is supposed to do and what the width means (final image width or amount to trim). Nevertheless, I cannot get the -set option to work.

Base image:
Image

Rotate by 2 deg:

Code: Select all

convert lena.jpg -rotate 2 lena_r2.png
Image

Deskew no auto-crop:

Code: Select all

convert lena_r2.png -deskew 40% lena_r2_deskew.png
Image


Deskew with auto-crop assuming width is amount to trim (10)

Code: Select all

convert lena_r2.png -set option:deskew:auto-crop 10 -deskew 40% lena_r2_deskew_ac10a.png
Image

I also tried using -define rather than -set option (assuming there is an equivalent)

Code: Select all

convert lena_r2.png -define deskew:auto-crop=10 -deskew 40% lena_r2_deskew_ac10b.png
And also setting a background color (white):

Code: Select all

convert lena_r2.png -background white -set option:deskew:auto-crop 10 -deskew 40% lena_r2_deskew_ac10c.png
But none of the auto-crop commands worked.


P.S. If there is a -define equivalent, then please add to the -defines on the options page.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Possible bug -deskew auto-crop IM 6.9.5.4 Q16 Mac OSX

Post by fmw42 »

Any work on confirming this issue?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Possible bug -deskew auto-crop IM 6.9.5.4 Q16 Mac OSX

Post by magick »

You can use -define deskew:auto-crop=10, we'll update the web page. When we used this option, here is the affine matrix it returned:
  • 0.999571 -0.0292843 0.0292843 0.999571 0 0
The results look reasonable.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Possible bug -deskew auto-crop IM 6.9.5.4 Q16 Mac OSX

Post by fmw42 »

Neither -set option or -define crop the image on my IM 6.9.5.5 Q16 Mac OSX. I get the same result as if I had not added the -set or -define.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Possible bug -deskew auto-crop IM 6.9.5.4 Q16 Mac OSX

Post by magick »

The documentation is wrong. The deskew:auto-crop has a value or true or false.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Possible bug -deskew auto-crop IM 6.9.5.4 Q16 Mac OSX

Post by fmw42 »

That changes things.

But in my test, it only trims off the extra white on the north and west edges. The results still show a white border on the east (right) and south (bottom).
Post Reply