Index: /trunk/admin/configuration.php
===================================================================
--- /trunk/admin/configuration.php	(revision 14648)
+++ /trunk/admin/configuration.php	(revision 14649)
@@ -455,6 +455,4 @@
       }
 
-      $common_quality = 50;
-
       $tpl_vars = array();
       foreach(ImageStdParams::get_all_types() as $type)
@@ -487,15 +485,9 @@
           }
           $tpl_var['sharpen'] = $params->sharpen;
-          $tpl_var['quality'] = $params->quality;
-          
-          if ($params->quality > $common_quality and $tpl_var['enabled'])
-          {
-            $common_quality = $params->quality;
-          }
         }
         $tpl_vars[$type]=$tpl_var;
       }
       $template->assign('derivatives', $tpl_vars);
-      $template->assign('resize_quality', $common_quality);
+      $template->assign('resize_quality', ImageStdParams::$quality);
     }
 
Index: /trunk/admin/include/configuration_sizes_process.inc.php
===================================================================
--- /trunk/admin/include/configuration_sizes_process.inc.php	(revision 14648)
+++ /trunk/admin/include/configuration_sizes_process.inc.php	(revision 14649)
@@ -98,5 +98,5 @@
       $errors[$type]['w'] = '>0';
     }
-    
+
     $h = intval($pderivative['h']);
     if ($h <= 0)
@@ -104,5 +104,5 @@
       $errors[$type]['h'] = '>0';
     }
-    
+
     if (max($w,$h) <= $prev_w)
     {
@@ -117,5 +117,5 @@
       $errors[$type]['w'] = '>'.$prev_w;
     }
-    
+
     $v = intval($pderivative['h']);
     if ($v <= 0 or $v <= $prev_h)
@@ -124,5 +124,5 @@
     }
   }
-  
+
   if (count($errors) == 0)
   {
@@ -130,4 +130,10 @@
     $prev_h = intval($pderivative['h']);
   }
+
+  $v = intval($pderivative['sharpen']);
+  if ($v<0 || $v>100)
+  {
+    $errors[$type]['sharpen'] = '[0..100]';
+  }
 }
 
@@ -135,4 +141,7 @@
 if (count($errors) == 0)
 {
+  $quality_changed = ImageStdParams::$quality != intval($_POST['resize_quality']);
+  ImageStdParams::$quality = intval($_POST['resize_quality']);
+
   $enabled = ImageStdParams::get_defined_type_map();
   $disabled = @unserialize( @$conf['disabled_derivatives'] );
@@ -146,5 +155,5 @@
   {
     $pderivative = $pderivatives[$type];
-    
+
     if ($pderivative['enabled'])
     {
@@ -156,9 +165,8 @@
           )
         );
-      
-      $new_params->quality = intval($_POST['resize_quality']);
-      
+      $new_params->sharpen = intval($pderivative['sharpen']);
+
       ImageStdParams::apply_global($new_params);
-      
+
       if (isset($enabled[$type]))
       {
@@ -170,5 +178,5 @@
           $same = false;
         }
-        
+
         if ($same
             and $new_params->sizing->max_crop != 0
@@ -177,10 +185,11 @@
           $same = false;
         }
-        
-        if ($new_params->quality != $old_params->quality)
+
+        if ($quality_changed
+            || $new_params->sharpen != $old_params->sharpen)
         {
           $same = false;
         }
-        
+
         if (!$same)
         {
@@ -210,5 +219,5 @@
     }
   }
-  
+
   $enabled_by = array(); // keys ordered by all types
   foreach(ImageStdParams::get_all_types() as $type)
@@ -219,5 +228,5 @@
     }
   }
-  
+
   ImageStdParams::set_and_save($enabled_by);
   if (count($disabled) == 0)
@@ -231,10 +240,10 @@
   }
   $conf['disabled_derivatives'] = serialize($disabled);
-  
+
   if (count($changed_types))
   {
     clear_derivative_cache($changed_types);
   }
-  
+
   array_push(
     $page['infos'],
@@ -257,5 +266,5 @@
     }
   }
-  
+
   $template->assign('derivatives', $pderivatives);
   $template->assign('ferrors', $errors);
Index: /trunk/admin/include/image.class.php
===================================================================
--- /trunk/admin/include/image.class.php	(revision 14648)
+++ /trunk/admin/include/image.class.php	(revision 14649)
@@ -288,6 +288,6 @@
   static function get_sharpen_matrix($amount)
   {
-    // Amount should be in the range of 28-10
-    $amount = round(abs(-28 + ($amount * 0.18)), 2);
+    // Amount should be in the range of 48-10
+    $amount = round(abs(-48 + ($amount * 0.38)), 2);
 
     $matrix = array(
@@ -550,4 +550,10 @@
   function rotate($rotation)
   {
+    if ($rotation==90 || $rotation==270)
+    {
+      $tmp = $this->width;
+      $this->width = $this->height;
+      $this->height = $tmp;
+    }
     $this->add_command('rotate', -$rotation);
     $this->add_command('orient', 'top-left');
@@ -563,5 +569,4 @@
   function resize($width, $height)
   {
-    $this->add_command('interlace', 'line');
     $this->add_command('filter', 'Lanczos');
     $this->add_command('resize', $width.'x'.$height.'!');
@@ -596,4 +601,6 @@
   function write($destination_filepath)
   {
+    $this->add_command('interlace', 'line'); // progressive rendering
+
     $exec = $this->imagickdir.'convert';
     $exec .= ' "'.realpath($this->source_filepath).'"';
@@ -612,5 +619,9 @@
     @exec($exec, $returnarray);
 
-    //echo($exec);
+    ilog($exec);
+    if (is_array($returnarray) && (count($returnarray)>0) )
+    {
+      ilog($returnarray);
+    }
     return is_array($returnarray);
   }
Index: /trunk/admin/themes/default/template/configuration.tpl
===================================================================
--- /trunk/admin/themes/default/template/configuration.tpl	(revision 14648)
+++ /trunk/admin/themes/default/template/configuration.tpl	(revision 14649)
@@ -432,4 +432,12 @@
         </tr>
   {/if}
+				<tr>
+				<td>{'Sharpen'|@translate}</td>
+				<td>
+					<input type="text" name="d[{$type}][sharpen]" maxlength="4" size="4"  value="{$d.sharpen}"{if isset($ferrors.$type.sharpen)} class="dError"{/if}>
+					%
+					{if isset($ferrors.$type.sharpen)}<span class="dErrorDesc" title="{$ferrors.$type.sharpen}">!</span>{/if}
+				</td>
+				</tr>
       </table> {* #sizeEdit *}
     </td>
Index: /trunk/i.php
===================================================================
--- /trunk/i.php	(revision 14648)
+++ /trunk/i.php	(revision 14649)
@@ -583,5 +583,5 @@
 }
 
-$image->set_compression_quality( $params->quality );
+$image->set_compression_quality( ImageStdParams::$quality );
 $image->write( $page['derivative_path'] );
 $image->destroy();
Index: /trunk/include/derivative_params.inc.php
===================================================================
--- /trunk/include/derivative_params.inc.php	(revision 14648)
+++ /trunk/include/derivative_params.inc.php	(revision 14649)
@@ -241,5 +241,4 @@
   public $sizing;
   public $sharpen = 0;
-  public $quality = 95;
 
   function __construct($sizing)
@@ -250,5 +249,5 @@
   public function __sleep()
   {
-      return array('last_mod_time', 'sizing', 'sharpen', 'quality');
+      return array('last_mod_time', 'sizing', 'sharpen');
   }
 
Index: /trunk/include/derivative_std_params.inc.php
===================================================================
--- /trunk/include/derivative_std_params.inc.php	(revision 14648)
+++ /trunk/include/derivative_std_params.inc.php	(revision 14649)
@@ -52,4 +52,5 @@
   private static $watermark;
   public static $custom = array();
+  public static $quality=95;
 
   static function get_all_types()
@@ -110,4 +111,5 @@
       self::$custom = @$arr['c'];
       if (!self::$custom) self::$custom = array();
+      if (isset($arr['q'])) self::$quality = $arr['q'];
     }
     else
@@ -115,4 +117,5 @@
       self::$watermark = new WatermarkParams();
       self::$type_map = self::get_default_sizes();
+      self::save();
     }
     self::build_maps();
@@ -137,4 +140,5 @@
     $ser = serialize( array(
       'd' => self::$type_map,
+      'q' => self::$quality,
       'w' => self::$watermark,
       'c' => self::$custom,
Index: /trunk/language/en_UK/admin.lang.php
===================================================================
--- /trunk/language/en_UK/admin.lang.php	(revision 14648)
+++ /trunk/language/en_UK/admin.lang.php	(revision 14649)
@@ -918,3 +918,4 @@
 $lang['%d second'] = '%d second';
 $lang['%d seconds'] = '%d seconds';
+$lang['Sharpen'] = 'Sharpen';
 ?>
