I did something like
convert -page A4 -compress A4 *.png CH00.pdf
But the 1st page is much larger than the subsequent pages. This happens even though the image dimensions are similar. These images are scanned & cropped thus may have slight differences in dimensions
I thought -page A4
should fix the size of the pages?
Best Answer
Last time I used
convert
for such a task I explicitly specified the size of the destination via resizing:The
convert
command doesn't always use DPI as default density/page format unit, thus we explicitly specify DPI with the-units
option (otherwise you may get different results with different versions/input format combinations). The new size (specified via-resize
) is the dimension of a DIN A4 page in pixels. The resize argument specifies the maximal page size. What resolution and quality to pick exactly depends on the use case - I selected 150 DPI and average quality to save some space while it doesn't look too bad when printed on paper.Note that
convert
by default does not change the aspect ratio with the resize operation:(ImageMagick manual)
Depending on the ImageMagick version and the involved input formats it might be ok to omit the
-repage
option. But sometimes it is required and without that option the PDF header might contain too small dimensions. In any case, the-repage
shouldn't hurt.The computations use integer arithmetic since
bash
only supports that. Withzsh
the expressions can be simplified - i.e. replaced with$((i*8.27))x$((i*11.69))
.Lineart Images
If the PNG files are bi-level (black & white a.k.a lineart) images then the
img2pdf
tool yields superior results over ImageMagickconvert
. That meansimg2pdf
is faster and yields smaller PDFs.Example:
or: