I want to batch convert images (jpg, png, etc.) to PDF. Converting them directly to PDF is easy with:
convert in.jpg out.pdf
However I need some more options, such as setting the output page size, margins and rotation between landscape and portrait format. After some trial and error I have come up with:
convert -rotate "90>" -page A4+0+0 -gravity center in.jpg out.pdf
This centers the image on an A4 page and automatically rotates between landscape and portrait, however it only works with small images below 595x842. Larger images break, as 595x842 seems to be the resolution in pixel that is assigned to an A4 page. Reading around on the net,
-density option might be a potential solution to increase the pixel count on an A4 page, but I couldn't make it work.
Solutions outside of Imagemagick are of course welcome as well.