Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageMagick Crop Tall image into A4 PDF pages with same width dynamic height

how can we make a tall-dynamicheight-screenshot.png into onefile.pdf with multiple pages in A4 so it could be readable when its printed?

example like this :

enter image description here

into A4 pages like

enter image description here

so when we print it would be like

enter image description here

not like (unreadable)

enter image description here

like image 859
Adam Ramadhan Avatar asked Oct 29 '22 04:10

Adam Ramadhan


2 Answers

This is maybe good enough for a crude first approach - it doesn't look for good places (white space) to divide the pages along though, so it slices through the image at the bottom of your first page:

convert article.jpg -resize 2480x -crop 2480x3508 +repage result.pdf

enter image description here

like image 184
Mark Setchell Avatar answered Nov 24 '22 00:11

Mark Setchell


In imagemagick you can crop to multiple pages. But it depends upon whether you want to keep your original size or resize the width to correspond to A4. The A4 file dimensions are 595x842.

If you want to keep the original dimensions and create a multipage PDF, then you will get 12 pages at your original resolution

convert V0twr.jpg -crop 595x842 +repage onefile1.pdf

If you want to resize to the width of an A4 and then crop, then you will get 2 pages at reduced resolution.

convert V0twr.jpg -resize 595x -crop 595x842 +repage onefile2.pdf

You can choose some other in-between resolution for your resize, if you want as a compromise, say twice the width of A4 = 2*595 = 1180

like image 27
fmw42 Avatar answered Nov 23 '22 23:11

fmw42