Deskew Text, maintain Text size & Original Dimensions...

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
tackd
Posts: 42
Joined: 2013-12-30T07:39:08-07:00
Authentication code: 6789

Deskew Text, maintain Text size & Original Dimensions...

Post by tackd » 2018-10-24T03:27:38-07:00

System; Linux Mint 18.3
ImageMagick 6.8.9-9 Q16 x86_64 2018-09-28

Source: US Letter Scanned Typed Letter (2550 x 3300 x 300 dpi)

Objective;
  • deskew
  • maintain original text size (no magnification)
  • resulting size same as original (2550 x 330 x 300dpi)
I have tried many incarnations, the most recent is;

Code: Select all

$ convert img20181022_0003.png -set option:deskew:autocrop true -sigmoidal-contrast 10,50% -deskew 40% +repage img20181022_0003_%02d.png
Could someone please advise ?

Thank you much.

Regards

snibgo
Posts: 11932
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Deskew Text, maintain Text size & Original Dimensions...

Post by snibgo » 2018-10-24T04:40:13-07:00

See http://www.imagemagick.org/script/comma ... php#deskew . "auto-crop" needs a hyphen. Does that help?
snibgo's IM pages: im.snibgo.com

tackd
Posts: 42
Joined: 2013-12-30T07:39:08-07:00
Authentication code: 6789

Re: Deskew Text, maintain Text size & Original Dimensions...

Post by tackd » 2018-10-24T16:12:39-07:00

Code: Select all

convert img20181022_0003.png -set option:deskew:auto-crop true -sigmoidal-contrast 10,50% -deskew 40% +repage img20181022_0003_%02d.png
Original size: 2550 x 3300
Result size: 2452 x 3164

Does anyone know how to keep the original dimensions and size of the text unchanged after a deskew ?

Thank you.

Regards.

snibgo
Posts: 11932
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Deskew Text, maintain Text size & Original Dimensions...

Post by snibgo » 2018-10-24T16:31:50-07:00

I don't see how you can have both.

Suppose you have scanned a piece of paper at an angle. The image will have more pixels than you need, added "triangles". After the deskew and auto-trim, those triangles will have been cropped off, so the image will be smaller than the scan.

You can "-extent" to make it the same size as the scan, if you want.
snibgo's IM pages: im.snibgo.com

tackd
Posts: 42
Joined: 2013-12-30T07:39:08-07:00
Authentication code: 6789

Re: Deskew Text, maintain Text size & Original Dimensions...

Post by tackd » 2018-10-24T17:10:33-07:00

Snibgo,

Thank you for your input.

After much experimentaion, and removing the "auto-crop", I added your suggestion, (-extent 2550x3300).

Code: Select all

convert img20181022_0003.png -sigmoidal-contrast 10,50% -deskew 40% -extent 2550x3300 img20181022_0003.tif
Result: 2550x3300 (Finally ! Thanks again)

Works, but I get an error "convert: TIFF: negative image positions unsupported"

Is it possible to maintain the original margin from the left of the page after a deskew ?
e.g. Original white margin, left side, 1 inch, before text begins.

Desired Result: 1 inch left margin before text begins, after the deskew ?

Regards

snibgo
Posts: 11932
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Deskew Text, maintain Text size & Original Dimensions...

Post by snibgo » 2018-10-24T18:16:44-07:00

Is that an error or warning? Anyhow, I suggest you "+repage" after any deskew, crop etc, unless you know you don't want to.

"-extent" is sensitive to "-gravity". Perhaps "-gravity East" does what you want.
snibgo's IM pages: im.snibgo.com

tackd
Posts: 42
Joined: 2013-12-30T07:39:08-07:00
Authentication code: 6789

Re: Deskew Text, maintain Text size & Original Dimensions...

Post by tackd » 2018-10-25T05:54:12-07:00

Thanks for all your help snibgo.

I ended up with;

Code: Select all

convert img20181022_0003.png -filter catrom -sigmoidal-contrast 10,50% -deskew 40% +repage -gravity south -extent 2550x3300 img20181022_0003.tif
Best regards

Post Reply