[magick-users] -deskew with autocrop

duc.sequere.aut.de.via.decede at imagemagick.org duc.sequere.aut.de.via.decede at imagemagick.org
Sat Mar 28 15:50:23 PDT 2009


> convert -set 'option:deskew:auto-crop 10' scan9.pnm scan92.pnm

Notice the option:deskew.  This means it only works with the -deskew option.
Also don't use the quotes.  We'll fix the documentation.

Programmically we auto crop by running a median filter across the image
to eliminate salt-n-pepper noise.  Next we get the image bounds of the
median filter image with a fuzz factor (e.g. -fuzz 5%).  Finally we
crop the original image by the bounds.  The code looks like this:

  median_image=MedianFilterImage(image,0.0,exception);
  geometry=GetImageBoundingBox(median_image,exception);
  print("  Auto-crop geometry: %lux%lu%+ld%+ld",geometry.width,geometry.height,
    geometry.x,geometry.y);
  crop_image=CropImage(rotate_image,&geometry,exception);


More information about the Magick-users mailing list