Search code examples
splitcropimagemagick-convert

Crop pdf file using ImageMagick


I have a pdf file (invoice) that i need to split into smaller images for each part of the invoice. I tried, but i only figured out how to cut it in two or in four equal parts using this command:

 convert -density 200 -resize 100% -crop 2x1@  +repage INVOICE.pdf INVOICEOut.pdf

following is the result i want to achieve:

INVOICE


Solution

  • Crop into 2 (equal) parts top and bottom. Then crop the top part into two (equal) parts left and right. (Unix Syntax)

    convert -density 200 invoice.pdf -crop 100x50% +repage \
    \( -clone 0 -crop 50x100% +repage -reverse \) -delete 0 -reverse -invoice_out.pdf
    


    Or find the locations of the top left corners of each section you want and their width and height and just crop each part. With clones and parenthesis processing you can crop as many areas as you want in one command line.