Index: /extensions/GThumb/admin.php
===================================================================
--- /extensions/GThumb/admin.php	(revision 12690)
+++ /extensions/GThumb/admin.php	(revision 12691)
@@ -9,4 +9,12 @@
 include(dirname(__FILE__).'/config_default.inc.php');
 $params = $conf['GThumb'];
+
+// Delete cache
+if (isset($_GET['deletecache']))
+{
+  check_pwg_token();
+  gtdeltree(GTHUMB_CACHE_DIR);
+  redirect('admin.php?page=plugin-GThumb');
+}
 
 // Save configuration
@@ -60,4 +68,19 @@
 );
 
+// Informations
+$data = gtdirsize(GTHUMB_CACHE_DIR);
+if ($data['size'] > 1024 * 1024)
+  $data['size'] = round($data['size'] / (1024 * 1024), 2).' MB';
+else
+  $data['size'] = round($data['size'] / 1024, 2).' KB';
+
+$template->assign(
+  array(
+    'NB_ELEMENTS' => l10n_dec('%d photo', '%d photos', $data['nb_files']),
+    'ELEMENTS_SIZE' => $data['size'],
+    'PWG_TOKEN' => get_pwg_token(),
+  )
+);
+
 $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/template/admin.tpl'));
 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
Index: /extensions/GThumb/functions.inc.php
===================================================================
--- /extensions/GThumb/functions.inc.php	(revision 12690)
+++ /extensions/GThumb/functions.inc.php	(revision 12691)
@@ -131,3 +131,32 @@
 }
 
+function gtdirsize($path, &$size=0, &$nb_files=0)
+{
+  if (is_dir($path))
+  {
+    $fh = opendir($path);
+    while ($file = readdir($fh))
+    {
+      if ($file != '.' and $file != '..' and $file != 'index.htm')
+      {
+        $pathfile = $path . '/' . $file;
+        if (is_dir($pathfile))
+        {
+          $data = gtdirsize($pathfile, $size, $nb_files);
+        }
+        else
+        {
+          $size += filesize($pathfile);
+          $nb_files++;
+        }
+      }
+    }
+    closedir($fh);
+  }
+  return array(
+    'size' => $size,
+    'nb_files' => $nb_files,
+  );
+}
+
 ?>
Index: /extensions/GThumb/js/gthumb.js
===================================================================
--- /extensions/GThumb/js/gthumb.js	(revision 12690)
+++ /extensions/GThumb/js/gthumb.js	(revision 12691)
@@ -73,5 +73,5 @@
 
       // Compute best size for landscape picture (we choose bigger height)
-      min_ratio = Math.min(1, this.big_thumb.width/this.big_thumb.height);
+      min_ratio = Math.min(1.05, this.big_thumb.width/this.big_thumb.height);
 
       for(width = this.big_thumb.width; width/best_size.height>=min_ratio; width--) {
@@ -118,5 +118,5 @@
       }
       this.t[0].crop = best_size.width;
-      this.resize(first_thumb, this.big_thumb.width, this.big_thumb.height, best_size.width, best_size.height, 'crop');
+      this.resize(first_thumb, this.big_thumb.width, this.big_thumb.height, best_size.width, best_size.height, true);
 
     }
@@ -164,5 +164,5 @@
             new_width = Math.round(new_width);
           }
-          this.resize(jQuery('#gt'+thumb_process[j].id), thumb_process[j].width, thumb_process[j].height, new_width, new_height, this.method);
+          this.resize(jQuery('#gt'+thumb_process[j].id), thumb_process[j].width, thumb_process[j].height, new_width, new_height, false);
 
           width_count += new_width + this.margin;
@@ -177,5 +177,5 @@
     // Last line does not need to be cropped
     for (j=0;j<thumb_process.length;j++) {
-      this.resize(jQuery('#gt'+thumb_process[j].id), thumb_process[j].width, thumb_process[j].height, thumb_process[j].width, max_height, this.method);
+      this.resize(jQuery('#gt'+thumb_process[j].id), thumb_process[j].width, thumb_process[j].height, thumb_process[j].width, max_height, false);
     }
 
@@ -185,13 +185,25 @@
   },
 
-  resize: function(thumb, width, height, new_width, new_height, method) {
-
-    if (method == 'resize') {
+  resize: function(thumb, width, height, new_width, new_height, is_big) {
+
+    if (this.method == 'resize') {
+      real_width = Math.min(new_width, width);
+      real_height = Math.min(new_height, height);
+      width_crop = 0;
+      height_crop = 0;
+
+      if (is_big) {
+        if (width - new_width > height - new_height) {
+          real_width = Math.round(new_height * width / height);
+          width_crop = Math.round((real_width - new_width)/2);
+        } else {
+          real_height = Math.round(new_width * height / width);
+          height_crop = Math.round((real_height - new_height)/2);
+        }
+      }
       thumb.css({
-        height: new_height+'px',
-        width: new_width+'px'
+        height: real_height+'px',
+        width: real_width+'px'
       });
-      height_crop = 0;
-      width_crop = 0;
     } else {
       thumb.css({height: '', width: ''});
Index: /extensions/GThumb/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/GThumb/language/en_UK/plugin.lang.php	(revision 12690)
+++ /extensions/GThumb/language/en_UK/plugin.lang.php	(revision 12691)
@@ -6,4 +6,6 @@
 $lang['Cache the big thumbnails (recommended)'] = 'Cache the big thumbnails (recommended)';
 $lang['Scale thumbnails'] = 'Scale thumbnails';
+$lang['Cache Informations'] = 'Cache Informations';
+$lang['Clear the cache'] = 'Clear the cache';
 
 ?>
Index: /extensions/GThumb/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/GThumb/language/fr_FR/plugin.lang.php	(revision 12690)
+++ /extensions/GThumb/language/fr_FR/plugin.lang.php	(revision 12691)
@@ -6,4 +6,6 @@
 $lang['Cache the big thumbnails (recommended)'] = 'Mettre en cache les grosse miniatures (recommandé)';
 $lang['Scale thumbnails'] = 'Redimensionner les miniatures';
+$lang['Cache Informations'] = 'Informations du cache';
+$lang['Clear the cache'] = 'Effacer le cache';
 
 ?>
Index: /extensions/GThumb/template/admin.tpl
===================================================================
--- /extensions/GThumb/template/admin.tpl	(revision 12690)
+++ /extensions/GThumb/template/admin.tpl	(revision 12691)
@@ -50,5 +50,16 @@
 </form>
 
+<fieldset id="cacheinfo">
+<legend>{'Cache Informations'|@translate}</legend>
+<p>
+{$NB_ELEMENTS}, {$ELEMENTS_SIZE}<br>
+<a href="admin.php?page=plugin-GThumb&amp;pwg_token={$PWG_TOKEN}&amp;deletecache=true" onclick="return confirm('{'Are you sure?'|@translate}');">{'Clear the cache'|@translate}</a>
+</p>
+</fieldset>
+
 {html_head}{literal}
-<style type="text/css">#GThumb td { padding-bottom: 12px; }</style>
+<style type="text/css">
+#GThumb td { padding-bottom: 12px; }
+#cacheinfo p { text-align:left; line-height:20px; margin:20px }
+</style>
 {/literal}{/html_head}
Index: /extensions/GThumb/template/gthumb.css
===================================================================
--- /extensions/GThumb/template/gthumb.css	(revision 12690)
+++ /extensions/GThumb/template/gthumb.css	(revision 12691)
@@ -16,2 +16,6 @@
   position: absolute;
 }
+
+.thumbnail, .thumbnail:hover {
+  border: 0 none;
+}
Index: /extensions/GThumb/template/gthumb.tpl
===================================================================
--- /extensions/GThumb/template/gthumb.tpl	(revision 12690)
+++ /extensions/GThumb/template/gthumb.tpl	(revision 12691)
@@ -18,8 +18,7 @@
 GThumb.margin = {$GThumb.margin};
 GThumb.method = '{$GThumb.method}';
-
+GThumb.small_thumb = {ldelim}id:{$small_thumb.id},src:'{$small_thumb.src}',width:{$small_thumb.width},height:{$small_thumb.height}{rdelim};
 {if isset($big_thumb)}
 GThumb.big_thumb = {ldelim}id:{$big_thumb.id},src:'{$big_thumb.src}',width:{$big_thumb.width},height:{$big_thumb.height}{rdelim};
-GThumb.small_thumb = {ldelim}id:{$small_thumb.id},src:'{$small_thumb.src}',width:{$small_thumb.width},height:{$small_thumb.height}{rdelim};
 {/if}
 
