I found some answers to this question but somehow nothing works for me (even though logically it should, at least with my knowledge)
I have three images file1.png
, file2.png
and file3.png
with these properties:
identify file*.png
file1.png PNG 4961x7016 4961x7016+0+0 8-bit sRGB 12.6135MiB 0.000u 0:00.000
file2.png PNG 4961x7016 4961x7016+0+0 8-bit sRGB 22.8132MiB 0.000u 0:00.000
file3.png PNG 4961x7016 4961x7016+0+0 8-bit sRGB 14.887MiB 0.000u 0:00.000
now I used this imagemagick command convert file*.png -page A4 file.pdf
to make a pdf with one image at each page. The problem with that one is, that the resulting pdf is with 52 MB way too big (since the input pictures are huge too). In addition, my pdfviewer displays me that the resulting pdf has a papersize of 25×36 mm
(A10) instead of the desired 210×297 mm
(A4).
I already tried to work with resize, but somehow I don't quite understand how set the sizes to get a A4 output (this is my main goal for now).
Does someone know why page A4
didn't work or how to actually get an output pdf with the papersize of A4
?
PS:
convert -version
Version: ImageMagick 7.0.10-25 Q16 x86_64 2020-08-01 https://imagemagick.org
Copyright: © 1999-2020 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5)
Delegates (built-in): bzlib cairo djvu fontconfig freetype heic jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png raqm raw rsvg tiff webp wmf x xml zlib
EDIT1 (identify output):
identify -verbose file.pdf
Image:
Filename: file.pdf
Format: PDF (Portable Document Format)
Mime type: application/pdf
Class: DirectClass
Geometry: 71x101+0+0
Resolution: 72x72
Print size: 0.986111x1.40278
Units: Undefined
Colorspace: sRGB
Type: TrueColorAlpha
Base type: Undefined
Endianness: Undefined
Depth: 16/8-bit
[...]
identify file.pdf
file.pdf[0] PDF 71x101 71x101+0+0 16-bit sRGB 7412B 0.000u 0:00.000
file.pdf[1] PDF 71x101 71x101+0+0 16-bit sRGB 11518B 0.000u 0:00.000
file.pdf[2] PDF 71x101 71x101+0+0 16-bit sRGB 8394B 0.000u 0:00.000
EDIT2: See two test pngs here (https://mega.nz/folder/O4Fm1aoK#ppeQD4ZycDMKhC2DctJ-UA) (sadly I cannot upload the pdf to stackOverflow)
This works for me if I add the units and density in ImageMagick.
convert Untitled* -units pixelsperinch -density 72 -resize 595x842 result.pdf
identify -verbose result.pdf
Image:
Filename: result.pdf
Format: PDF (Portable Document Format)
Mime type: application/pdf
Class: DirectClass
Geometry: 595x841+0+0
Resolution: 72x72
Print size: 8.26389x11.6806
...
You may have found a deficiency in ImageMagick. The units and density need to be provided, I believe, since PNG stores that information in pixelspercentimeter, but PDF needs it in pixelsperinch.