Cutting an image in two, cropping margins

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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

That page you refer to gives all the info you need.

Crop the image in two using

Code: Select all

   convert input.png -crop 50x100%+0+0  +repage left_page.png
   convert input.png -gravity East -crop 50x100%+0+0  +repage right_page.png
trim however is a problem. First you have a dark edge around the page that will interfer, so use -shave to remove say 20 pixels or so.

Next you are using a bitmap image (1 bit grey), as such you will probbaly need to use a blurred trim technique (perhaps with a -despeckle) so your trim ignores small pixels clumps and trim to the larger clumps of pixels.

Note also that with -trim your final page images may be different sizes.

PS: you may have been better off using a greyscale rather than bitmap scan of the book.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply