Page 1 of 1

Annotate with leading zeros?

Posted: 2019-07-01T05:48:32-07:00
by rylander
I'm creating a numbered image sequence using:
for i in `seq 001 300`
do convert -size 2048x1080 xc:none -font arial -fill black -pointsize 48 -annotate +100+100 $i output_$(printf %04d $i).png
done

This works well but I would like the annotation text to be 001, 002, etc. rather than 1,2,3,10,13,137.
How do I do that?

Re: Annotate with leading zeros?

Posted: 2019-07-01T06:13:40-07:00
by snibgo
The obvious answer is: use the same trick in annotate as you use for the output filename.

Re: Annotate with leading zeros?

Posted: 2019-07-01T06:42:44-07:00
by rylander
Obviously thank you.

Re: Annotate with leading zeros?

Posted: 2019-07-01T07:29:39-07:00
by GeeMack
rylander wrote: 2019-07-01T05:48:32-07:00This works well but I would like the annotation text to be 001, 002, etc. rather than 1,2,3,10,13,137.
In many installations the "seq" command will take an argument so it will include the leading zeros in the output. On mine it's "-w". Maybe try something like this...

Code: Select all

... seq -w 1 300 ...

Re: Annotate with leading zeros?

Posted: 2019-07-01T09:10:15-07:00
by snibgo
Good point, GeeMack. "seq" from Cygwin has "-w", automatically choosing the required number of leading zeros.

I can also...

Code: Select all

seq -f %06g 1 300
... to get six digits, so three or more leading zeros.