Index: /trunk/gsdl/bin/script/buildcol.pl
===================================================================
--- /trunk/gsdl/bin/script/buildcol.pl	(revision 1266)
+++ /trunk/gsdl/bin/script/buildcol.pl	(revision 1267)
@@ -54,5 +54,9 @@
     print STDERR "   -keepold              will not destroy the current contents of the\n";
     print STDERR "                         building directory\n";
-    print STDERR "   -allclassifications   Don't remove empty classifications\n\n";
+    print STDERR "   -allclassifications   Don't remove empty classifications\n";
+    print STDERR "   -create_images        Attempt to create default images for new\n";
+    print STDERR "                         collection. This relies on the Gimp being\n";
+    print STDERR "                         installed along with relevant perl modules\n";
+    print STDERR "                         to allow scripting from perl\n\n";
 }
 
@@ -61,5 +65,6 @@
 {
     my ($verbosity, $archivedir, $cachedir, $builddir, $maxdocs, 
-	$debug, $mode, $indexname, $keepold, $allclassifications);
+	$debug, $mode, $indexname, $keepold, $allclassifications,
+	$create_images);
     if (!parsargv::parse(\@ARGV, 
 			 'verbosity/\d+/2', \$verbosity,
@@ -72,5 +77,6 @@
 			 'index/.*/', \$indexname,
 			 'keepold', \$keepold,
-			 'allclassifications', \$allclassifications)) {
+			 'allclassifications', \$allclassifications,
+			 'create_images', \$create_images)) {
 	&print_usage();
 	die "\n";
@@ -85,5 +91,5 @@
     # read the configuration file
     $textindex = "section:text";
-    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc/collect.cfg");
+    $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg");
     if (-e $configfilename) {
 	$collectcfg = &colcfg::read_collect_cfg ($configfilename);
@@ -101,4 +107,13 @@
     }
     
+    # create default images if required
+    if ($create_images) {
+	my $collection_name = $collection;
+	$collection_name = $collectcfg->{'collectionmeta'}->{'collectionname'} 
+	if defined $collectcfg->{'collectionmeta'}->{'collectionname'};
+	
+	&create_images ($collection_name);
+    }
+
     # fill in the default archives and building directories if none
     # were supplied, turn all \ into / and remove trailing /
@@ -177,3 +192,53 @@
 }
 
-
+sub create_images {
+    my ($collection_name) = @_;
+
+    my $image_script = &util::filename_cat ($ENV{'GSDLHOME'}, "bin", "script", "gimp", "title_icon.pl");
+    if (!-e $image_script) {
+	print STDERR "WARNING: Image making script ($image_script) could not be found\n";
+	print STDERR "         Default images will not be generated\n\n";
+	return;
+    }
+
+    my $imagedir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "images");
+
+    &util::mk_all_dir ($imagedir);
+
+    # create the images
+    system ("$image_script -size 1.5 -image_dir \"$imagedir\" -filename $collection.gif -text \"$collection_name\"");
+    system ("$image_script -image_dir \"$imagedir\" -filename ${collection}sm.gif -text \"$collection_name\"");
+
+    # update the collect.cfg configuration file (this will need
+    # to be changed when the config file format changes)
+    if (!open (CFGFILE, $configfilename)) {
+	print STDERR "WARNING: Couldn't open config file ($configfilename)\n";
+	print STDERR "         for updating so collection images may not be linked correctly\n";
+	return;
+    }
+
+    my $line = ""; my $file = "";
+    my $found = 0; my $foundsm = 0;
+    while (defined ($line = <CFGFILE>)) {
+	if ($line =~ /collectionmeta\s+iconcollection\s+/) {
+	    $line = "collectionmeta iconcollection _httprefix_/collect/$collection/images/$collection.gif\n";
+	    $found = 1;
+	} elsif ($line =~ /collectionmeta\s+iconcollectionsmall\s+/) {
+	    $line = "collectionmeta iconcollectionsmall _httprefix_/collect/$collection/images/${collection}sm.gif\n";
+	    $foundsm = 1;
+	}
+	$file .= $line;
+    }
+    close CFGFILE;
+
+    $file .= "collectionmeta iconcollection _httprefix_/collect/$collection/images/$collection.gif\n" if !$found;
+    $file .= "collectionmeta iconcollectionsmall _httprefix_/collect/$collection/images/${collection}sm.gif\n" if !$foundsm;
+
+    if (!open (CFGFILE, ">$configfilename")) {
+	print STDERR "WARNING: Couldn't open config file ($configfilename)\n";
+	print STDERR "         for updating so collection images may not be linked correctly\n";
+	return;
+    }
+    print CFGFILE $file;
+    close CFGFILE;
+}
Index: /trunk/gsdl/bin/script/gimp/title_icon.pl
===================================================================
--- /trunk/gsdl/bin/script/gimp/title_icon.pl	(revision 1266)
+++ /trunk/gsdl/bin/script/gimp/title_icon.pl	(revision 1267)
@@ -46,8 +46,8 @@
 
 
-my ($cfg_file, $imagefile, $width, $height, $imageheight, $stripecolor, $stripewidth, 
-    $stripe_alignment, $i_transparency, $text, $text_alignment, $filename, $textspace_x, 
-    $textspace_y, $bgcolor, $fontcolor, $fontsize, $minfontsize, $fontname, 
-    $fontweight, $fontslant, $fontwidth, $fontspacing, $image_dir);
+local ($cfg_file, $size, $imagefile, $width, $height, $imageheight, $stripecolor, $stripewidth, 
+       $stripe_alignment, $i_transparency, $text, $text_alignment, $filename, $textspace_x, 
+       $textspace_y, $bgcolor, $fontcolor, $fontsize, $minfontsize, $fontname, 
+       $fontweight, $fontslant, $fontwidth, $fontspacing, $image_dir, $dont_wrap);
 
 sub print_usage {
@@ -57,4 +57,6 @@
     print STDERR "                          sets of the following options - use to create\n";
     print STDERR "                          batches of images\n";
+    print STDERR "   -size number           the overall size ratio of the image (i.e. a size\n";
+    print STDERR "                          of 2 will create an image twice the default size)\n";
     print STDERR "   -image_dir directory   directory to create images in [`pwd`]\n";
     print STDERR "                          this should be full path to existing directory\n";
@@ -83,5 +85,6 @@
     print STDERR "   -fontslant             [r]\n";
     print STDERR "   -fontwidth             [*]\n";
-    print STDERR "   -fontspacing           [*]\n\n";
+    print STDERR "   -fontspacing           [*]\n";
+    print STDERR "   -dont_wrap             don't attempt to wrap text\n\n";
 }
 
@@ -89,9 +92,9 @@
     $image_dir = "./";
     $imagefile = "";
-    $width = 150;
-    $height = 44;
-    $imageheight = 110;
+    $width = int (150 * $size);
+    $height = int (44 * $size);
+    $imageheight = int (110 * $size);
     $stripecolor = $gsdl_green;
-    $stripewidth = 40;
+    $stripewidth = int (40 * $size);
     $stripe_alignment = "left";
     $i_transparency = 60;
@@ -99,10 +102,10 @@
     $text_alignment = "left";
     $filename = "";
-    $textspace_x = 3;
-    $textspace_y = 3;
+    $textspace_x = int (3 * $size);
+    $textspace_y = int (3 * $size);
     $bgcolor = $gsdl_green;
     $fontcolor = $black;
-    $fontsize = 17;
-    $minfontsize = 10;
+    $fontsize = int (17 * $size);
+    $minfontsize = int (10 * $size);
     $fontname = "lucida";
     $fontweight = "medium";
@@ -116,4 +119,5 @@
     if (!parsargv::parse(\@ARGV, 
 			 'cfg_file/.*/', \$cfg_file,
+			 'size/\d+/1', \$size,
 			 'image_dir/.*/./', \$image_dir,
 			 'imagefile/.*/', \$imagefile,
@@ -138,5 +142,6 @@
 			 'fontslant/.*/r', \$fontslant,
 			 'fontwidth/.*/*', \$fontwidth,
-			 'fontspacing/.*/*', \$fontspacing)) {
+			 'fontspacing/.*/*', \$fontspacing,
+			 'dont_wrap', \$dont_wrap)) {
 	&print_usage();
 	die "title_icon.pl: incorrect options\n";
@@ -148,5 +153,5 @@
 	chomp $image_dir;
     }
-    
+
     if ($cfg_file =~ /\w/) {
 	
@@ -177,4 +182,7 @@
 
 sub produce_image {
+
+    &adjust_args ();
+    &wrap_text () unless $dont_wrap;
 
     my $use_image = 0;
@@ -338,4 +346,36 @@
     return 1;
 }
+
+# adjust arguments that are effected by the size argument
+sub adjust_args {    
+
+    if ($size != 1) {
+	my @size_args = ('width', 'height', 'imageheight', 'stripewidth',
+			 'textspace_x', 'textspace_y', 'fontsize', 'minfontsize');
+	foreach $arg (@size_args) {
+	    $$arg = int ($$arg * $size);
+	}
+    }
+}
+
+sub wrap_text {
+
+    # don't wrap text if it already contains carriage returns
+    return if $text =~ /\n/;
+
+    # the following assumes that all words are less than $wrap_length long
+    my $wrap_length = 14;
+
+    my $new_text = "";
+    while (length ($text) >= $wrap_length) {
+	my $line = substr ($text, 0, $wrap_length);
+	$text =~ s/^$line//;
+	$line =~ s/\s([^\s]*)$/\n/;
+	$text = $1 . $text;
+	$new_text .= $line;
+    }
+    $new_text .= $text;
+    $text = $new_text;
+}
     
 sub query {
