possible bug -deskew crop IM 6.8.2.8 Q16

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 crop IM 6.8.2.8 Q16

Post by fmw42 »

IM 6.8.2.8 Q16 Mac OSX Snow Leopard

Seems like the auto-cropping is done first, but perhaps it should be done after the deskew.

Input:
Image

This works fine:
convert zelda3_r4.png -deskew 40% show:

But this seems to crop first and then deskew.
convert zelda3_r4.png -set option:deskew:auto-crop 20 -deskew 40% show:


Is this working the way intended?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug -deskew crop IM 6.8.2.8 Q16

Post by magick »

The image is deskewed, then auto-cropped.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -deskew crop IM 6.8.2.8 Q16

Post by fmw42 »

This does not look right to me.

Input:
Image

This works fine:
convert zelda3_r4.png -deskew 40% zelda3_r4_deskew.jpg
Image

But this is not what I would expect for a post deskew center crop or shave.
convert zelda3_r4.png -set option:deskew:auto-crop 20 -deskew 40% zelda3_r4_deskew_crop20.jpg
Image
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug -deskew crop IM 6.8.2.8 Q16

Post by magick »

Auto-cropping is not an exact science. This command works for this image and may not work for others:
  • convert -bordercolor white zelda3_r4.png -set option:deskew:auto-crop 1 -deskew 40% -fuzz 15% -trim show:
Take a look at magick/shear.c/DeskewImage(). Perhaps you can improve the algorithm.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -deskew crop IM 6.8.2.8 Q16

Post by fmw42 »

magick wrote:Auto-cropping is not an exact science. This command works for this image and may not work for others:
  • convert -bordercolor white zelda3_r4.png -set option:deskew:auto-crop 1 -deskew 40% -fuzz 15% -trim show:

I think I must not understand auto-crop. The docs on the options page say

"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)."

So I assumed that width meant the amount of trimming to be done something like -shave.

I will discuss with you offline and perhaps I can update the docs once I understand more what it is doing.

Fred
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug -deskew crop IM 6.8.2.8 Q16

Post by magick »

The pixel width is the amount of the pixels around the border of the image to use when determining the image background color. If the image border is not consistent, auto-cropping will not work.
Post Reply