Alex Schuster on  wrote...
| FINALLY, a question I can answer!
| 
And a good answer it was.  However as I have been doing scripts like
this for almost 20 years, (Am I that old?)  I had a few comments to
add...

| 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
| >

Using some expert knowledge of both Shell and IM...

using 301 converts...

  seq 0 300 | xargs -i@ convert -size 720x480 -gravity center label:@ @.png

OR using one convert! (may be memory hungry)

   convert -size 720x480 -gravity center \
           `seq -f 'label:%g' 0 300` +adjoin %d.png

The above requires the 'seq' command which is available under linux.
'xargs' is a command that was available from the earliest UNIX releases.

| > --------------------( 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) 

Actually it is still /bin/sh  which is a symbolic link to /bin/bash
but causes BASH to fall backto bourne shell complience mode.

That is it would work very well.

| has a different syntax, see below. Other points, image-magick related:
|   - The size argument must be one word, without spaces in it

OR quoted!!!!

|   - The font argument will not work I think. Try convert -list font
|     for the list of fonts installed on your system.

They gave a X11 font name, which is supossed to work, but only if you
are running on an X window display, such that IM can access it to 'draw'
the font.

But it does need to be quoted due to the meta-character '*' in it.

It also should be on the same line as -font for readability.

This worked for me...
    convert -font '-*-Times-*' label:tiny x:

Though the result was a small italic bold font, as I did not specify
which 'Times' font I wanted.   You can get a list of available X window
fonts using  "xlsfonts"

|   - -draw needs the final text to be in extra quotes
Yeap, and those either need to be escaped, or different to the
surrounding quotes.
See  Draw, To Quote or Backslash...
   http://imagemagick.org/Usage/draw/#quote

|   - I think mogrify just converts existing images. Use convert instead,
|     and provide a black input image with xc:black
| 
Mogrify modifys a list of images and writes then mack to the same file
unless you speciay a different output  -format   or  destination -path
Both can be used at the same time. See
   http://imagemagick.org/Usage/basics/#mogrify

| > 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
| 
quite reasonable and expandable.
Though I don't think the use wants different colors.

  Anthony Thyssen ( System Programmer )    <[EMAIL PROTECTED]>
 -----------------------------------------------------------------------------
  Applications Programming is a race between software engineers striving
  to build bigger and better idiot-proof programs, and the Universe trying
  to produce bigger and better idiots.  So far, the Universe is winning.
                                     -- Rick Cook, "The Wizardry Compiled"
 -----------------------------------------------------------------------------
     Anthony's Home is his Castle     http://www.cit.gu.edu.au/~anthony/
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to