Stitch scanned images using CLI
I have scanned a newspaper article which was larger than the scanner glass. Each page was scanned twice: the top and the bottom parts, where the middle part appeared in both images.
Is there a way to quickly match and stitch these scanned images, preferably using CLI? The panorama stitching tools I know require lengthy configuration, which is mostly irrelevant: lens size, focus, angle etc.
Hugin has a solution for this issue, but it isn't practical for batch jobs.
Solution 1:
You could play around with ImageMagick's montage
tool. You'll want to install the imagemagick
package before you go any further.
At face value, you just need to ply montage
with input files and then give it an output file:
montage scan1.jpg scan2.jpg output.jpg
but montage
can get really powerful. You can pass along various translation arguments if you need to rotate the pages before they're combined. You can read an extended manual on it here.
Solution 2:
Ok, in really what you need is ImageMagick, install it sudo apt-get install imagemagick
and then you just need to do these steps:
- create a blank image in the parameters to fit the two images that you need to put together.
- type in the terminal:
composite -gravity North top_scan.jpg blank_image.jpg top_image.jpg
- type in the terminal:
composite -gravity South bottom_scan.jpg top_image.jpg complete_image.jpg
But if you need something that autorotate the images to get them perfectly matching, sorry, but as far as I know there isn't anything that do it in ubuntu.