imagemagickimagemagick-convert

ImageMagick: convert image to PDF with A4 page size and image fit to page


I want to convert different image formats (bmp,jpg,gif,png,tiff-incluging multipaged) into a PDF format with A4 page size and with images fit to page (resized if necessary). Image should be positioned at the center of the page and I'd like to define an offset. I tried the code below but there is no offset at the top and the image quality is really poor.

convert png.png -gravity North -resize 500x500 -quality 100 -page a4x5x5 myout.pdf

Is there any way to do that?

Thanks in advance for any help, Mariusz


Solution

  • Thanks to the ImageMagick support forum I was able to find a solution:

    convert image.tif -resize 575x823^> -gravity center -background white -extent 595x842 image.pdf
    

    If you get an error try:

    convert image.tif -resize 595x842^\> -gravity center -background white -extent 595x842 image.pdf