=== lib/TWiki/Plugins/ImageGalleryPlugin.pm
==================================================================
--- lib/TWiki/Plugins/ImageGalleryPlugin.pm   (/ImageGalleryPlugin/trunk)   (revision 291)
+++ lib/TWiki/Plugins/ImageGalleryPlugin.pm   (/ImageGalleryPlugin/branches/robustness)   (revision 291)
@@ -41,19 +41,22 @@
         return 0;
     }
 
-    # Get plugin preferences, the variable defined by:          * Set CONVERT = ...
-    $IMAGE_MAGICK = &TWiki::Prefs::getPreferencesValue( "IMAGEGALLERYPLUGIN_IMAGE_MAGICK" ) || "/usr";
-    $CONVERT = &TWiki::Prefs::getPreferencesValue( "IMAGEGALLERYPLUGIN_CONVERT" ) || "$IMAGE_MAGICK/bin/convert";
-    $IDENTIFY = &TWiki::Prefs::getPreferencesValue( "IMAGEGALLERYPLUGIN_IDENTIFY" ) || "$IMAGE_MAGICK/bin/identify";
-    $CONVERT_OPTIONS = &TWiki::Prefs::getPreferencesValue('IMAGEGALLERYPLUGIN_CONVERT_OPTIONS');
+    # Get plugin preferences.  We use values from TWiki.cfg because
+    # only the site administrator may change these settings for security reasons.
 
+    # The following settions are recommended:
+    # $ImageGalleryPlugin_CONVERT = '/usr/bin/convert -sample %RESIZE|N% %SOURCE|F% %TARGET|F%';
+    # $ImageGalleryPlugin_IDENTIFY = '/usr/bin/identify %FILE|F%';
+
+    $CONVERT = $TWiki::ImageGalleryPlugin_CONVERT;
+    $IDENTIFY = $TWiki::ImageGalleryPlugin_IDENTIFY;
+
     # Get plugin debug flag
     $debug = &TWiki::Func::getPreferencesFlag( "IMAGEGALLERYPLUGIN_DEBUG" );
 
     if ( $debug ) {
-	&TWiki::Func::writeDebug( "image_magick=[$IMAGE_MAGICK]" );
-	&TWiki::Func::writeDebug( "convert=[$CONVERT]: " . ((-x $CONVERT) ? 'found executable' : 'missing') );
-	&TWiki::Func::writeDebug( "identify=[$IDENTIFY]: " . ((-x $IDENTIFY) ? 'found executable' : 'missing'));
+	&TWiki::Func::writeDebug( "convert=[$CONVERT]");
+	&TWiki::Func::writeDebug( "identify=[$IDENTIFY]");
 	# Plugin correctly initialized
 	&TWiki::Func::writeDebug( "- TWiki::Plugins::ImageGalleryPlugin::initPlugin( $web.$topic ) is OK" );
     }
@@ -92,13 +95,15 @@
     {
 	$i->{humanReadableSize} = sprintf( "%dk", $i->{size}/1024 );
 	my $fn = &TWiki::Func::getPubDir() . "/$web/$topic/$i->{name}";
-	my $thumb = &TWiki::Func::getPubDir() . "/$web/$topic/thumbs/$resize/$i->{name}";
+	my $thumb = TWiki::normalizeFileName (&TWiki::Func::getPubDir() . "/$web/$topic/thumbs/$resize/$i->{name}");
 
 	&TWiki::Func::writeDebug( Dumper( $i ) ) if $debug;
 
-	next unless (my $dimensions = `"$IDENTIFY" "$fn"`) =~
-	    m/(\d+)x(\d+)/; # fix, else don't work for jpg, png ...!
-	    #m/(\d+)x(\d+)\+(\d+)\+(\d+)/;
+	my ($dimensions, $exitcode) = TWiki::readFromProcess ($IDENTIFY, FILE => $fn);
+	unless ($dimensions =~ m/(\d+)x(\d+)/) {
+	    &TWiki::Func::writeDebug( $dimensions ) if $debug;
+	    next;
+	}
 
 	$inr++;
 	my ( $width, $height ) = ( $1, $2 );
@@ -114,13 +119,14 @@
 
 	unless ( ( -M $thumb ) && ( -M $fn > -M $thumb ) )
 	{   # only update the thumbnail if (1) it doesn't exist or (2) the thumbnail is older than the source image
-	    my $thumbDir = &TWiki::Func::getPubDir() . "/$web/$topic/thumbs";
+	    my $thumbDir = TWiki::normalizeFileName (&TWiki::Func::getPubDir() . "/$web/$topic/thumbs");
 	    mkdir $thumbDir unless -d $thumbDir;
-	    $thumbDir .= "/$resize";
+	    $thumbDir = TWiki::normalizeFileName ("$thumbDir/$resize");
 	    mkdir $thumbDir unless -d $thumbDir;
 
 	    &TWiki::Func::writeDebug( "- running CONVERT" ) if $debug;
-	    system( qq{$CONVERT -sample $resize $options "$fn" "$thumb"} );
+            my ($output, $code) = TWiki::readFromProcess ($CONVERT, SOURCE => $fn, TARGET => $thumb, RESIZE => $resize);
+	    &TWiki::Func::writeDebug( "CONVERT result: '$output', status $code" ) if $debug;
 	}
     }
 
=== data/TWiki/ImageGalleryPlugin.txt
==================================================================
--- data/TWiki/ImageGalleryPlugin.txt   (/ImageGalleryPlugin/trunk)   (revision 291)
+++ data/TWiki/ImageGalleryPlugin.txt   (/ImageGalleryPlugin/branches/robustness)   (revision 291)
@@ -1,5 +1,5 @@
-%META:TOPICINFO{author="RobertSuna" date="1075560360" format="1.0" version="1.3"}%
-%META:TOPICPARENT{name="TWikiPreferences"}%
+%META:TOPICINFO{author="RobertSuna" date="1075560360" format="1.0" version="1.3"}%
+%META:TOPICPARENT{name="TWikiPreferences"}%
 ---++ TWiki Image Gallery Plugin
 
 Pages containing ==%<nop>IMAGEGALLERY%== variables are expanded at view time, providing a thumbnailed image gallery for those images attached to a wiki page.  Thumbnails are created automatically and subsequently cached.  Display is simple ( trivial--probably not really good enough, although each picture is surrounded by a =span= with a class of =imgGallery= )
@@ -85,14 +85,6 @@
 		* Set LARGE = 150x150
 		* Set XLARGE = 250x250
 
-	* Name and location of program used to generate thumbnails
-		* Set IMAGE_MAGICK = /usr
-		* Set CONVERT = /usr/bin/convert
-		* Set IDENTIFY = /usr/bin/identify
-
-	* Additionaly program options for the CONVERT program
-		* Set CONVERT_OPTIONS = ""
-
 	* One line description, is shown in the %TWIKIWEB%.TextFormattingRules topic:
 		* Set SHORTDESCRIPTION = Displays image gallery with auto-generated thumbnails for attachments.
 
@@ -109,6 +101,12 @@
 	  | ==data/TWiki/%TOPIC%.txt,v== | Plugin topic repository |
 	  | ==lib/TWiki/Plugins/%TOPIC%.pm== | Plugin Perl module |
 	  | ==pub/TWiki/%TOPIC%/twikiwide.gif== | test image for this page |
+        * Edit your =TWiki.cfg= file and set the path to ImageMagick:
+          <verbatim>
+          $ImageGalleryPlugin_CONVERT = '/usr/bin/convert -sample %RESIZE|N% %SOURCE|F% %TARGET|F%';
+          $ImageGalleryPlugin_IDENTIFY = '/usr/bin/identify %FILE|F%';
+          </verbatim>
+          (The path =/usr/bin/= may need adjusting.)
 
 ---++ Plugin Info
 
@@ -128,4 +126,4 @@
 __Related Topics:__ %TWIKIWEB%.TWikiPreferences, %TWIKIWEB%.TWikiPlugins
 
 -- Main.WillNorris - 1 Aug 2003 <br>
-%META:FILEATTACHMENT{name="twikiwide.gif" attr="" comment="" date="1059773705" path="twikiwide.gif" size="5850" user="WillNorris" version="1.1"}%
+%META:FILEATTACHMENT{name="twikiwide.gif" attr="" comment="" date="1059773705" path="twikiwide.gif" size="5850" user="WillNorris" version="1.1"}%
=== data/TWiki/ImageGalleryPlugin.txt,v
==================================================================
Cannot display: file marked as a binary type.

Property changes on: 
___________________________________________________________________
Name: svk:merge
 +49f547e0-b4e8-0310-9e4c-ee56684d2241:/ImageGalleryPlugin/trunk:268
Name: svm:source
 +svn://subversion.enyo.de/twiki!/ImageGalleryPlugin/branches/robustness
Name: svm:uuid
 +0d0f78c6-ffe8-0310-8651-bed26cca55cd

