Montage with numbered tiles

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
dirk
Posts: 2
Joined: 2011-05-17T07:32:55-07:00
Authentication code: 8675308

Montage with numbered tiles

Post by dirk »

Hi,

I would like to number the tiles in an image created with 'montage' so that the first tile (=file) gets the number 1, the second the number 2, and so on..

My command at the moment looks like this:

Code: Select all

montage -label '???' *.png -tile 20x5 -geometry 300x1800 -debug cache montage20x5.jpg
Thanks for help,

Dirk
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Montage with numbered tiles

Post by fmw42 »

You have to use -set label after the input images. This works:

montage zelda3.png lena2.png -set label '%[fx:t+1]' tmp.png

see fx where t = scene number of current image in sequence (starts with 0)

http://www.imagemagick.org/Usage/montage/#label
http://www.imagemagick.org/script/fx.php
http://www.imagemagick.org/Usage/transform/#fx_escapes
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Montage with numbered tiles

Post by anthony »

WARNING this will however only work with the latest versions of IM where the '%[fx:t]' and the '%t' settings have been fixed.
Hmmm from IM v6.6.8-6 onward. Before this you would only get a value of zero, and not the current image index.

As you can see you can use the index as part of a mathematical expression using FX :-)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
dirk
Posts: 2
Joined: 2011-05-17T07:32:55-07:00
Authentication code: 8675308

Re: Montage with numbered tiles

Post by dirk »

Great, this works.

For my example, the command for indexing with 'montage' looks as follows:

Code: Select all

montage -set label '%[fx:t+1]' *.png -tile 20x5 -geometry 300x1800 -debug cache montage20x5.jpg
Thanks,

Dirk
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Montage with numbered tiles

Post by anthony »

The -set works with actual images. Put it AFTER reading in the images. This may error in the future!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply