Merging multiple images into one document and add any caption/label to them

I have multiple jpg and png images. I would like to combine them within one document (ODT/PDF/RTF). It can be easily done by means of following command:

convert *.png allTogether.pdf

However, there will be no labels/captions/file names, so that it will be difficult to for example ensure which image we're displaying now in current PDF page.

Is there any ready solution to merge images to one PDF and attach any metadata to them (for example file name)? I thought about writing a script which will generate LaTeX document, but maybe there're simpler ways.


Solution 1:

You already use the right tool e.g.

convert *.png -gravity South -annotate 0 '%f' all.pdf

Here you can find more examples: http://www.imagemagick.org/Usage/annotating/

Solution 2:

I came with this command. You can use it for every picture.

convert  "a.jpg"  -fill white -undercolor '#0000' -pointsize 15 -gravity north  -annotate +0+5 "a.jpg" "new-a.pdf"

enter image description here

enter image description here

Explanation:

  • -fill white : The caption font color
  • -undercolor '#0000' the background color of the span of the caption
  • -pointsize 15 : font size 15
  • -gravity north : caption is in north which means in top
  • -annotate +0+5 "a.jpg" "new-a.jpg" : annotate by +5

Then convert the output to a.pdf