Search code examples
imagemagick

How do I label magick-montage images without their extension?


I can montage a few images (for demonstration here converted from text), but the label option includes the full filenames—with their extension.

target:
    for number in {1..6}; do \
        convert -gravity center -background SkyBlue -size 96x96 label:$$number -pointsize 24 $$number.png; \
    done
    montage -density 225 -label '%f' *.png -tile 3x -shadow -geometry '+8+8>'  all.jpg

How do I label magick-montage images without their extension?

montage of images along with their filenames

(In other words, I'd like the label under the image for 1 to be 1, not 1.png.)


Solution

  • In Imagemagick, %f means the full image.suffix, but %t is just the image (name) without the suffix. So replace %f with %t in your montage command. See https://imagemagick.org/script/escape.php for all the % string formats.