Page 1 of 1

Deskew() in Perl

Posted: 2011-01-15T03:04:15-07:00
by romey-rome
Hi,

Can someone explain this:

Deskew geometry=>string,threshold=>double

I don't understand what it's looking for. I always got the results I got from the command line with simply -deskew 40%, but I'm unsure how to get the same results with PerlMagick (geometry of what? threshold of 0.0-1.0, or 0-100, ?).

Thanks!

Re: Deskew() in Perl

Posted: 2011-01-15T08:53:06-07:00
by magick
Use $image->Deskew('40%'). If you use the threshold parameter it is scaled from 0 to QuantumRange. For the Q16 version of ImageMagick, use a value from 0 to 65535.

Re: Deskew() in Perl

Posted: 2011-01-15T14:38:48-07:00
by romey-rome
Thanks for the reply.

Unfortunately, that was the first thing I tried. I get my tif, but it does no Deskewing.

Code: Select all

sub do_magick {
        my $im = Image::Magick->new;
        my $ppm = $_[0];
        $im->Read($ppm);
        $im->Deskew('40%');
        $im->Write($basenm . "_pldk.tif");
}
ImageMagick-6.6.7-0
ImageMagick-perl-6.6.7-0
ImageMagick-devel-6.6.7-0

Re: Deskew() in Perl

Posted: 2011-01-15T19:26:07-07:00
by magick
ImageMagick cannot deskew every image. It is sensitive to the image and the threshold. Post a URL to your image here so we can reproduce the problem and trace why ImageMagick does not discover the deskewing factor.

Re: Deskew() in Perl

Posted: 2011-01-15T19:37:03-07:00
by fmw42
From my limited experience with -deskew (in command line) it works best for images rotated or skewed less than 5 degrees. Above that the results are problematic. I have an unrotate bash shell script that works for larger rotations (see link below). But I have no idea how to convert it to PerlMagick.

Re: Deskew() in Perl

Posted: 2011-01-15T21:07:34-07:00
by romey-rome
I'll try to get a non-company document working sample.

Just to add, the document I am trying in Perl deskews perfectly with convert.