FINALLY, a question I can answer!
zimbot writes:
> I have been trying to make seq of images .
> I have tried mostly on windows - but i have also tried linux sh.
> nether of my efforts have worked.
>
> goal :: create 300 pngs , size = 720x480 , each is Black with white
> text of 1 incrementing to 300 , 0-300.pngs
>
> --------------------( linix
>
> in a file make300.sh
>
> #!/bin/sh
> for i while i<300
> do
> echo $i
> mogrify -normalize \\
> -size 720 x 480 \\
> -bordercolor yellow -border 5 \\
> -fill white \\
> -font \\
> -*-Times \\
> -gravity center \\
> -draw 'text 20,20 $i\\
> $i.png
> $i=$i+1
> done
Um, this doesn't look so good. /bin/sh (which is /bin/bash under linux)
has a different syntax, see below. Other points, image-magick related:
- The size argument must be one word, without spaces in it
- The font argument will not work I think. Try convert -list font
for the list of fonts installed on your system.
- -draw needs the final text to be in extra quotes
- I think mogrify just converts existing images. Use convert instead,
and provide a black input image with xc:black
> so you see I wish to make a bunch pf pngs that have a count up
> ( actually i hope to increment the background color also from black to
> a dark grey. )
Ah, so the xc:black must become a variable color, too. Those are specified
in hexadecimal notation like #rrggbb. For grey, rr, gg, and bb are the
same values, incrementing from 00 (black) to something like 80 (dark
grey), while white would be 255. So we calculate it as 80 * i / 300.
Using printf, we can output these values in hex notation which IM needs.
I also use printf in order to generate names with leading zeros. Let's
make the 300 and 80 variables, too. Which gives this script:
#!/bin/bash
n=300
darkgrey=80
for (( i=0; i < n; i++ ))
do
color=$( printf "%02x" $(( darkgrey * i / n )) )
printf "Creating file %3d with color %s..." $i "$color"
convert -normalize \
-size 720x480 \
-bordercolor yellow \
-border 5 \
-fill white \
-font "Times-New-Roman" \
-gravity center \
-draw "text 20,20 '$i'" \
xc:\#$color$color$color "$( printf "%03d" $i ).png"
printf " OK\n"
done
You may even paste the whole loop (without the #!/bin/bash) into your
terminal, so there is no need to save this script into a file and make it
executable.
Wonko
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users