Trimming scanned images with random borders?
Posted: 2017-09-12T10:49:44-07:00
Hi *,
I could use some help as I'm new to ImageMagick. I started doing the work (manually) with Photoshop, but quickly realized that both my time and my sanity would expire before getting through. When looking around for automated solutions, I found that if any software could, most likly ImageMagick would do the job.
(Sorry that the explanation is not as short as I would have liked. Well, it's according to the problem...)
I need to trim/crop around 1000+ scanned images: The scanner detects the page size automatically, and most of the time got it right. However, a lot of images show additional borders which I need to remove.
This is (the link to) a demonstration image without page contents, but clearly showing the page edge shadows on three sides:
https://www.dropbox.com/s/htldz4q4zh50bgq/C600_086.tif
The additional borders are detectable because
But the main point is -- I don't have a clue how to detect the inner edge; and I don't know how to leave alone an edge if it has no extra border.
Any help would be very much appreciated.
Tnx,
Tillomar
PS: Forgot to mention -- ImageMagick 7.0.7-Q16 x84 on Win7
I could use some help as I'm new to ImageMagick. I started doing the work (manually) with Photoshop, but quickly realized that both my time and my sanity would expire before getting through. When looking around for automated solutions, I found that if any software could, most likly ImageMagick would do the job.
(Sorry that the explanation is not as short as I would have liked. Well, it's according to the problem...)
I need to trim/crop around 1000+ scanned images: The scanner detects the page size automatically, and most of the time got it right. However, a lot of images show additional borders which I need to remove.
This is (the link to) a demonstration image without page contents, but clearly showing the page edge shadows on three sides:
https://www.dropbox.com/s/htldz4q4zh50bgq/C600_086.tif
The additional borders are detectable because
- the image size deviates from the default page size by more then +/- 20 px for each affected axis
- the scanner has the borders separated from the page contents by a small shadow which has a sharp edge to the page contents, but a blurry edge to the outside.
- extra border on the top has never a shadow, so trimming the top edge would have to be done using a standard page length after fixing the bottom edge
- The shadow width is variable between scans and along the edge; the position for trimming should therefore be the "inner" (sharp) edge, so the extra border is removed up to the inner edge of the shadow.
- if a page edge was detected properly, there is no shadow
- the extra border may be on any number (or no) side
But the main point is -- I don't have a clue how to detect the inner edge; and I don't know how to leave alone an edge if it has no extra border.
Any help would be very much appreciated.
Tnx,
Tillomar
PS: Forgot to mention -- ImageMagick 7.0.7-Q16 x84 on Win7