convert set of jpg files into huge pdf: how to add filenames

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
aloist
Posts: 2
Joined: 2013-10-01T05:30:43-07:00
Authentication code: 6789

convert set of jpg files into huge pdf: how to add filenames

Post by aloist »

I use 'convert' to create huge PDF files from a set of JPG images. Each image becomes one page in the resulting PDF.

is there a way to make the file names of the JPG files appear as well in the created PDF, as an annotation somewhere on each page?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: convert set of jpg files into huge pdf: how to add filen

Post by magick »

Try -set label %f.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert set of jpg files into huge pdf: how to add filen

Post by fmw42 »

If you do not mind the filenames add outside the image, then try

montage -label "%f" -tile 1x1 image1.jpg image2.jpg .... result.pdf
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert set of jpg files into huge pdf: how to add filen

Post by fmw42 »

Here is another way that lets you put the filename inside the image. You can place it with -gravity ... -geometry ...

convert image1.jpg image2.jpg ....imageN.jpg -set filename:myfilename '%f' \
-gravity north -pointsize 15 -fill white -annotate 0 "%[filename:myfilename]" result.pdf
aloist
Posts: 2
Joined: 2013-10-01T05:30:43-07:00
Authentication code: 6789

Re: convert set of jpg files into huge pdf: how to add filen

Post by aloist »

Thanks a lot for the swift and excellent help.

As these are grayscale scan documents, some near white, some near black, I used the third recommended version, with 'fill red'
and got escellent results.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: convert set of jpg files into huge pdf: how to add filen

Post by anthony »

Note I would not use filename:filename whcih is special for use in output filenames not for annotations

Why not just use %f directly in the annotation?

Code: Select all

convert image1.jpg image2.jpg ....imageN.jpg  \
         -gravity north -pointsize 15 -fill white -annotate 0 "%f" \
         result.pdf
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply