How to convert png to pdf with A4 dimensions using imagemagick?

I'm trying to use imagemagick cli in combination with powershell to convert a png image into pdf. I would like for the resulting pdf to be A4 landscape.

This is what I have come up with so far:

magick overview.png -page a4 -rotate -90 overview.pdf

Unfortunately my resulting pdf is not A4, being approximately 4x5 inches.

I'm not sure what I'm doing wrong here, since based on the docs a4 is a valid value for the -page parameter.

How can I convert the png to a pdf with A4 dimensions using the -page parameter?


Solution 1:

-page does not resize the image.

In ImageMagick, since about 7.1.0.13 or later, you can do

magick input -set option:dims "%[papersize:A4]" -resize "%[dims]" output

Or simpler,


magick input -resize "%[papersize:A4]" output

in order to resize to a given page size by name, such as A4.

(The name "dims" is not required. You can call it anything you want)