Page 1 of 1

Scaling various images to A4 size including borders

Posted: 2019-08-21T07:22:26-07:00
by tps800
Hi!

I am trying to scale and rotate various images to A4 size, then convert them to PDF and print them. But it does not work in any way reliable. Sometimes the images are printed as expected, sometimes they are rotated if not necessary. Most of the time the images are positioned with their left upper corner within the center of the page. Whatever I try it does not lead to what i'd like to have:
  1. make them portrait: shorter sides top and bottom, longer sides left and right.
  2. scale them to fit on A4, respecting borders all 1cm.
I've come as far as:

Code: Select all

/usr/bin/convert "file.png" -verbose -strip -background white -rotate "90>" -trim +repage -page "A4<" -gravity "center" -resize "98%>" PDF:file.pdf
Most of the time I get:
https://drive.google.com/file/d/1mTR5zZ ... sp=sharing

Any idea how I could get what I want: this image centered with a border of 1cm on A4 paper?

Re: Scaling various images to A4 size including borders

Posted: 2019-08-21T08:59:59-07:00
by fmw42
Post an input image so we can test with your command and then correct it.

Try replacing -page "A4<" with -resize WxH for the WxH corresponding to A4.

Re: Scaling various images to A4 size including borders

Posted: 2019-08-21T09:16:34-07:00
by fmw42
Try this

Code: Select all

convert -size 1000x842 pattern:checkerboard -background black -rotate "90>" -trim +repage -resize "595x842>" -gravity center -extent 595x842 result.png
If that works, replace the -size 1000x842 pattern:checkerboard with your image and then replace result.png with your file.pdf

I don't think you need the -trim +repage, but it won't hurt to leave it.