Reputation: 1071
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
Upvotes: 76
Views: 85165
Reputation: 5333
You need to specify the density:
magick -density 80 -page a4 input_A.jpg input_B.jpg output.pdf
Otherwise, there can be an issue when printing with "actual size" instead of "fit". I have used a public printer where I could not choose "fit" and had to choose "actual size", in which case the printed page was only a part of the page which I wanted to print.
Upvotes: 5
Reputation: 1847
If you want to keep the original resolution (lossless) you can try the following command:
magick png.png -background white -page a4 -gravity center myoutput.pdf
it does not upscale small images
Based on a comment posted before: https://stackoverflow.com/a/24573341/6747994
img2pdf -o output.pdf --pagesize A4 input.png
This command upscales small images, and will produce pixelated images
Upvotes: 83
Reputation: 2594
Found this somewhere on stackoverflow:
convert *.jpg -resize 1240x1753 \
-extent 1240x1753 -gravity center \
-units PixelsPerInch -density 150x150 multipage.pdf
Upvotes: 21
Reputation: 1713
You can convert to pdf using ImageMagick
convert png.png myout.pdf
but use pdfjam instead of ImageMagick to adjust the page size
pdfjam --paper a4paper --outfile myoutA4.pdf myout.pdf
pdfjam offers other options, which may fit your needs.
Upvotes: 28
Reputation: 1071
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
Upvotes: 14