Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageMagick 6.8.9-1 : PDF to JPG including crop to bounding box

PDFs that were used as source for printed media usually contain a bounding box with instructions for the printing facilities. If you open a PDF in a normal PDF Viewer, you don't see that extra white space around the page.

However if you use ImageMagick to convert a PDF (containing bounding box) to JPG, the JPG contains the white border.

How do you get rid of this bounding box?

Just as a hint: If you open a PDF in Adobe Photoshop you can choose the option "Crop to Bounding Box", that option I would like to use in ImageMagick but don't know how.

like image 949
basZero Avatar asked Aug 31 '25 10:08

basZero


1 Answers

ImageMagick has two options that allow you to use the CropBox or the TrimBox of your PDF document. I am not sure which one is the same as the bouding box in photoshop but you can use it like this:

convert -define pdf:use-cropbox=true -density 300 input.pdf output.jpg
convert -define pdf:use-trimbox=true -density 300 input.pdf output.jpg

Other PDF specific options can be found here: http://www.imagemagick.org/script/formats.php (scroll down to PDF)

like image 109
dlemstra Avatar answered Sep 06 '25 19:09

dlemstra