montage: label images with part of filename

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
stas_sl
Posts: 2
Joined: 2015-08-14T06:30:54-07:00
Authentication code: 1151

montage: label images with part of filename

Post by stas_sl »

I would like to montage multiple files with names like these:

Code: Select all

1235_9123a46d52ecb2de.png
123_6a51ef8968c64b94.png
1269_a7059318d47dbc01.png
12_45fb8c628863d77a.png
1347_04355d15f39e1e06.png
1349_bcbad21a686712d1.png
1368_229b9d3f692fdd61.png
1369_f69c36e04ba37bcb.png
137_ec3571cde47f7b8a.png
...
I want to label each image with only part of filename before underscore _

If I use the following command

Code: Select all

montage -label %t * show:
then whole filename is displayed that is quite long. Is it possible to extract substring from filenames somehow?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: montage: label images with part of filename

Post by snibgo »

I don't think you can do this directly. You could write a script to first assign labels, then use those labels in a single montage. The script would execute multiple commands like:

Code: Select all

convert 1235_9123a46d52ecb2de.png -set label 1235 1235_9123a46d52ecb2de.png
Then:

Code: Select all

montage -label %l * show:
snibgo's IM pages: im.snibgo.com
stas_sl
Posts: 2
Joined: 2015-08-14T06:30:54-07:00
Authentication code: 1151

Re: montage: label images with part of filename

Post by stas_sl »

Thanks, snibgo, good idea!
Post Reply