Index: directoryprovider.php
===================================================================
--- directoryprovider.php	(revision 64)
+++ directoryprovider.php	(working copy)
@@ -174,7 +174,7 @@
     return filemtime( $this->directoryBasePath . $path );
   }
 
-  function thumb( $path, $size ) {
-    return $this->thumbProvider->thumbUrl( $path, $size );
+  function thumb( $path, $width, $height ) {
+    return $this->thumbProvider->thumbUrl( $path, $width, $height );
   }
 }
Index: thumb.php
===================================================================
--- thumb.php	(revision 64)
+++ thumb.php	(working copy)
@@ -71,7 +71,7 @@
         return $this->group;
     }
 
-    function thumbUrl( $path, $size ) {
+    function thumbUrl( $path, $width, $height ) {
         Abort( "Gallery ". $this->group . " does not implement thumbnails" );
     }
 
@@ -89,11 +89,15 @@
         $this->phpThumbUrl = $phpThumbUrl;
     }
 
-    function thumbUrl( $path, $size ) {
-        if( $size==0 )
-            return $this->phpTHumbUrl . "?src=" . urlencode($path) . " ";
-        else
-            return $this->phpThumbUrl . "?w=" . urlencode($size) . "&src=" . urlencode($path) . " ";
+    function thumbUrl( $path, $width, $height ) {
+    	$url=$this->phpThumbUrl.'?';
+    	if ($width!=0) {
+    		$url .= 'w=' . urlencode($width) . '&';
+    	}
+    	if ($height!=0) {
+    		$url .= 'h=' . urlencode($height). '&';
+    	}
+        return $url . '&src=' . urlencode($path) . ' ';
     }
 }
 
@@ -131,17 +135,16 @@
         }
     }
 
-    function thumbUrl( $path, $size ) {
+    function thumbUrl( $path, $width, $height ) {
         global $WikiGallery_UseAuthorization, $pagename;
-    
         // we can use a direct url to the file if authorization is not needed
         if( !$WikiGallery_UseAuthorization ) {
-            if( $size==0 )
+            if( $width==0 && $height=0 )
                 // give direct url to the original file
                 return 'http://'.$_SERVER['HTTP_HOST']."/".preg_replace("/ /","%20", $this->picturesWebPath . $path);
             else {
                 // give direct url to the cache file
-                $thumbnail = $this->cacheFileName( $path, $size );
+                $thumbnail = $this->cacheFileName( $path, $width, $height );
                 $thumbname = $this->cacheBasePath . "/" . $thumbnail;
                 $originalname = $this->picturesBasePath . "/" . $path;
                 if( WikiGalleryIsFileAndNonZero($thumbname) && filemtime($thumbname)>=filemtime($originalname) ) {
@@ -156,10 +159,16 @@
     
         $picpage = $this->group . "." . fileNameToPageName($path);
         $url = MakeLink( $picpage, $picpage, NULL, NULL, "\$LinkUrl" );
-        if( $size==0 )
-            return $url . '?action=thumbnail&group=' . urlencode($this->group) . '&image=' . urlencode($path) . ' ';
-        else
-            return $url . '?action=thumbnail&width=' . $size . '&group=' . urlencode($this->group) . '&image=' . urlencode($path) . ' ';
+
+    	$url.='?action=thumbnail&';
+    	if ($width!=0) {
+    		$url .= 'width=' . urlencode($width) . '&';
+    	}
+    	if ($height!=0) {
+    		$url .= 'height=' . urlencode($height). '&';
+    	}
+        return $url . 'group=' . urlencode($this->group) . '&image=' . urlencode($path) . ' ';
+        
     }
   
     function cacheFileName( $path, $width=0, $height=0 ) {
Index: wikigallery.php
===================================================================
--- wikigallery.php	(revision 64)
+++ wikigallery.php	(working copy)
@@ -63,18 +63,18 @@
 ################################################################################
 
 // The markup:
-Markup('(:gallerypicture group? width picture:)',
+Markup('(:gallerypicture group? width? height? picture:)',
        '><|',
-       "/\\(:gallerypicture(\\s([^0-9][^\\s]+))?\\s([0-9]+)\\s([^:]*):\\)/e",
-       'WikiGalleryPicture( \'$2\', \'$3\',\'$4\')');
-Markup('(:gallerypicturerandom group? width album:)',
+       "/\\(:gallerypicture(\\s+([^0-9][^\\s]+))?(\\s+([0-9]+))?(\\s+([0-9]+))?\\s+([^:]+?)\\s*:\\)/e",
+       'WikiGalleryPicture( \'$2\',\'$4\',\'$6\',\'$7\')');
+Markup('(:gallerypicturerandom group? width? height? album:)',
        '><|',
-       "/\\(:gallerypicturerandom(\\s([^0-9][^\\s]+))?\\s([0-9]+)\\s([^:]*):\\)/e",
-       'WikiGalleryPicture( \'$2\', \'$3\',\'$4\', true)');
+       "/\\(:gallerypicturerandom(\\s+([^0-9][^\\s]+))?(\\s+([0-9]+))?(\\s+([0-9]+))?\\s+([^:]+?)\\s*:\\)/e",
+       'WikiGalleryPicture( \'$2\',\'$4\',\'$6\',\'$7\', true)');
 
-function WikiGalleryPicture( $group, $width, $path, $random=false ) {
+function WikiGalleryPicture( $group, $width, $height, $path, $random=false ) {
     $pagestore =& WikiGalleryPageStore( $group );
-    return $pagestore->picture( $width, $path, $random );
+    return $pagestore->picture( $width, $height, $path, $random );
 }
 
 // Page variables
@@ -158,7 +158,7 @@
     $WikiGallery_Size = intval($_GET["gallerysize"]);
     setcookie("gallerysize", $WikiGallery_Size, time()+3600);
 }
-if( $WikiGallery_Size<0 || $WikiGallery_Size>10000 ) {
+if( $WikiGallery_Size<0 || $WikiGallery_Size>1600 ) {
     $WikiGallery_Size = $WikiGallery_DefaultSize;
 }
 
@@ -207,7 +207,7 @@
     }
 
     // return the url to show a thumbnail of the given size
-    function thumb( $path, $size ) {
+    function thumb( $path, $width, $height ) {
         return false;
     }
 }
@@ -507,7 +507,7 @@
         }
     }
 
-    function picture( $size, $path, $random=false ) {
+    function picture( $width, $height, $path, $random=false ) {
         $path = WikiGallerySecurePath( $path );  
 
         // random picture?
@@ -522,6 +522,6 @@
         }
   
         // return phpthumb url
-        return $this->provider->thumb( $path, $size );
+        return $this->provider->thumb( $path, $width, $height );
     }
 }