On Sat, 19 Mar 2011 15:01:05 +0000 John Levin <technola...@gmail.com> wrote:
> hi all, > > I need several series of numbered icons, from about 1 to 111 in > different colours. There must be a way of automating this through the > command line using imagemagick, but I haven't found a way of doing > so, and my google - fu is giving very poor returns today. Any one got > any ideas? With no testing whatsoever, and only a passing (but google-enhanced) familiarity with imagemagick, this is how I'd do it in Perl. Basically, define an array of acceptable colours, then iterate through the numbers 1 through 111. For each, pick two different colours at random to use as foreground and background colours and create an icon. I don't even know if the imagemagick command really does what I want it to - I got it from [0] - and this could be done in any language, I just can't remember how to do arrays in bash. #! /usr/bin/perl my @colours=("red","green","blue","orange"); for (my $i = 1; $i <= 111; $i++) { # Pick a random colour for fg and bg out of the array: my $fgcolour = $colours(int rand($#colours +1)); my $bgcolour = $colours(int rand($#colours +1)); # Check they're not equal while ($bgcolour == $fgoclour){ $bgcolour = $colours(int rand($#colours +1)); } # Concoct a command my $cmd="convert -size 16x16 xc:$colour "; $cmd .= "-pointsize 8 -fill green "; $cmd .= "-stroke black "; $cmd .= " -draw 'text 10,55 \"$i\"' "; $cmd .= "icon_$i.jpg "; # Run it `$cmd`; } [0] http://www.imagemagick.org/Usage/draw/#specifics -- Avi -- ubuntu-uk@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-uk https://wiki.ubuntu.com/UKTeam/