narmi2
asked on
Command line image manipulation
Dear Experts,
Is it possible via command line to rotate an image automatically so it is perfectly straight? For example, lets say I scan in a document and the scan is slightly at an angle because the document was not inserted into the scanner properly. I know you can rotate the image using something like this:
convert -rotate 90 input.jpg output.jpg
But is it possible to automatically detect how much it needs to be rotated by to straighten it up?
Thanks
Is it possible via command line to rotate an image automatically so it is perfectly straight? For example, lets say I scan in a document and the scan is slightly at an angle because the document was not inserted into the scanner properly. I know you can rotate the image using something like this:
convert -rotate 90 input.jpg output.jpg
But is it possible to automatically detect how much it needs to be rotated by to straighten it up?
Thanks
ASKER
I can't figure out from that link how the program can automatically detect how much to rotate the scanned document to straighten it up.
I'm not sure how automatic it is based on your needs but the section that may be of use is the following.
as it says if you add -rotate -"90>" it will rotate and image if the width is more than the height. It's only automatic based on the criteria of either width less than height (>) or if width is less than height.
-rotate degrees{<}{>}
Apply Paeth image rotation (using shear operations) to the image.
Use > to rotate the image only if its width exceeds the height. < rotates the image only if its width is less than the height. For example, if you specify -rotate "-90>" and the image size is 480x640, the image is not rotated. However, if the image is 640x480, it is rotated by -90 degrees. If you use > or <, enclose it in quotation marks to prevent it from being misinterpreted as a file redirection.
Empty triangles in the corners, left over from rotating the image, are filled with the background color.
See also the -distort operator and specifically the 'ScaleRotateTranslate' distort method.
as it says if you add -rotate -"90>" it will rotate and image if the width is more than the height. It's only automatic based on the criteria of either width less than height (>) or if width is less than height.
-rotate degrees{<}{>}
Apply Paeth image rotation (using shear operations) to the image.
Use > to rotate the image only if its width exceeds the height. < rotates the image only if its width is less than the height. For example, if you specify -rotate "-90>" and the image size is 480x640, the image is not rotated. However, if the image is 640x480, it is rotated by -90 degrees. If you use > or <, enclose it in quotation marks to prevent it from being misinterpreted as a file redirection.
Empty triangles in the corners, left over from rotating the image, are filled with the background color.
See also the -distort operator and specifically the 'ScaleRotateTranslate' distort method.
ASKER
Here is an example scan image I want to straighten up
http://www.jonbenetindexguide.com/10131999-HunterGJ-Announcement-Pg2.gif
As you can see, this is slightly tilted. Can the above commands straighten this up without me telling it how much to straighten it up by?
http://www.jonbenetindexguide.com/10131999-HunterGJ-Announcement-Pg2.gif
As you can see, this is slightly tilted. Can the above commands straighten this up without me telling it how much to straighten it up by?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
See here.
http://www.imagemagick.org/script/command-line-options.php?ImageMagick=hjg5196r7dlcfpti6df137psp5#rotate