I have an image (png, size 4288×2848) that I want to fit in a landscape a5 pdf with a 1cm border.
I know I can do it with ImageMagick
but don't know how.
image manipulationimagemagick
I have an image (png, size 4288×2848) that I want to fit in a landscape a5 pdf with a 1cm border.
I know I can do it with ImageMagick
but don't know how.
Best Answer
A5
landscape size is210mmx148mm
.With a
1cm
border (i.e.10mm
) that means the image should be200mm
wide and138mm
high hence an aspect ratio of1.45
- and your original image (4288x2848
) is slightly wider:1.51
aspect ratio. You'll have to crop it first to4130x2848
so as to have the same aspect ratio.You could do that by simply using
-extent
e.g.will crop the image to the desired size leaving the top left corner unaffected
or you could instead crop relative to gravity e.g. center:
whichever suits you better...
Once you have the cropped image you can convert it to
pdf
; for a page sizeA5
e.g. @300px
per inch (which is equivalent to118px
per cm) the size of the canvas is2480x1748
however if you subtract the10mm
border which is118px
your image should be2362x1630
and the remaining is the white background so again, with the help of-extent
: