Index: /trunk/admin/include/functions_upload.inc.php
===================================================================
--- /trunk/admin/include/functions_upload.inc.php	(revision 8226)
+++ /trunk/admin/include/functions_upload.inc.php	(revision 8227)
@@ -85,4 +85,31 @@
       false
       );
+
+    if (is_imagick())
+    {
+      if ($conf['upload_form_hd_keep'])
+      {
+        $need_resize = need_resize($high_path, $conf['upload_form_hd_maxwidth'], $conf['upload_form_hd_maxheight']);
+        
+        if ($conf['upload_form_hd_resize'] and $need_resize)
+        {
+          pwg_image_resize(
+            false,
+            $high_path,
+            $high_path,
+            $conf['upload_form_hd_maxwidth'],
+            $conf['upload_form_hd_maxheight'],
+            $conf['upload_form_hd_quality'],
+            false
+            );
+          $high_infos = pwg_image_infos($high_path);
+        }
+      }
+      else
+      {
+        unlink($high_path);
+        $high_infos = null;
+      }
+    }
   }
 
@@ -251,5 +278,5 @@
   }
 
-  if (extension_loaded('imagick'))
+  if (is_imagick())
   {
     return pwg_image_resize_im($source_filepath, $destination_filepath, $max_width, $max_height, $quality, $strip_metadata);
@@ -521,3 +548,13 @@
   array_push($_SESSION['uploads_error'][$upload_id], $error_message);
 }
+
+function is_imagick()
+{
+  if (extension_loaded('imagick'))
+  {
+    return true;
+  }
+
+  return false;
+}
 ?>
Index: /trunk/admin/photos_add.php
===================================================================
--- /trunk/admin/photos_add.php	(revision 8226)
+++ /trunk/admin/photos_add.php	(revision 8227)
@@ -104,4 +104,41 @@
     'error_message' => l10n('The thumbnail image quality must be a number between %d and %d'),
     ),
+  
+  'hd_keep' => array(
+    'default' => true,
+    'can_be_null' => false,
+    ),
+  
+  'hd_resize' => array(
+    'default' => false,
+    'can_be_null' => false,
+    ),
+  
+  'hd_maxwidth' => array(
+    'default' => 2000,
+    'min' => 500,
+    'max' => 20000,
+    'pattern' => '/^\d+$/',
+    'can_be_null' => false,
+    'error_message' => l10n('The high definition maximum width must be a number between %d and %d'),
+    ),
+  
+  'hd_maxheight' => array(
+    'default' => 2000,
+    'min' => 500,
+    'max' => 20000,
+    'pattern' => '/^\d+$/',
+    'can_be_null' => false,
+    'error_message' => l10n('The high definition maximum height must be a number between %d and %d'),
+    ),
+  
+  'hd_quality' => array(
+    'default' => 95,
+    'min' => 50,
+    'max' => 100,
+    'pattern' => '/^\d+$/',
+    'can_be_null' => false,
+    'error_message' => l10n('The high definition image quality must be a number between %d and %d'),
+    ),
   );
 
Index: /trunk/admin/photos_add_settings.php
===================================================================
--- /trunk/admin/photos_add_settings.php	(revision 8226)
+++ /trunk/admin/photos_add_settings.php	(revision 8227)
@@ -46,24 +46,30 @@
   // settings
   $field = 'websize_resize';
+  $fields[] = $field;
   
-  if (empty($_POST[$field]))
-  {
-    $value = false;
-  }
-  else
+  if (!empty($_POST[$field]))
   {
     $fields[] = 'websize_maxwidth';
     $fields[] = 'websize_maxheight';
     $fields[] = 'websize_quality';
+  }
 
-    $value = true;
+  // hd_keep
+  $field = 'hd_keep';
+  $fields[] = $field;
+  
+  if (!empty($_POST[$field]))
+  {
+    $field = 'hd_resize';
+    $fields[] = $field;
+    
+    if (!empty($_POST[$field]))
+    {
+      $fields[] = 'hd_maxwidth';
+      $fields[] = 'hd_maxheight';
+      $fields[] = 'hd_quality';
+    }
   }
   
-  $updates[] = array(
-    'param' => 'upload_form_'.$field,
-    'value' => boolean_to_string($value),
-    );
-  $form_values[$field] = $value;;
-
   // and now other fields, processed in a generic way
   $fields[] = 'thumb_maxwidth';
@@ -78,7 +84,22 @@
       $value = $_POST[$field];
     }
-    $form_values[$field] = $value;
     
-    if ($upload_form_config[$field]['can_be_null'] and empty($value))
+    if (is_bool($upload_form_config[$field]['default']))
+    {
+      if (isset($value))
+      {
+        $value = true;
+      }
+      else
+      {
+        $value = false;
+      }
+
+      $updates[] = array(
+        'param' => 'upload_form_'.$field,
+        'value' => boolean_to_string($value)
+        );
+    }
+    elseif ($upload_form_config[$field]['can_be_null'] and empty($value))
     {
       $updates[] = array(
@@ -112,4 +133,6 @@
       }
     }
+    
+    $form_values[$field] = $value;
   }
 
@@ -136,11 +159,16 @@
 // +-----------------------------------------------------------------------+
 
-// specific case, "websize_resize" is a checkbox
-$field = 'websize_resize';
-$form_values[$field] = $form_values[$field] ? 'checked="checked"' : '';
+foreach (array_keys($upload_form_config) as $field)
+{
+  if (is_bool($upload_form_config[$field]['default']))
+  {
+    $form_values[$field] = $form_values[$field] ? 'checked="checked"' : '';
+  }
+}
 
 $template->assign(
     array(
       'F_ADD_ACTION'=> PHOTOS_ADD_BASE_URL,
+      'MANAGE_HD' => is_imagick(),
       'values' => $form_values
     )
Index: /trunk/admin/themes/default/template/photos_add_settings.tpl
===================================================================
--- /trunk/admin/themes/default/template/photos_add_settings.tpl	(revision 8226)
+++ /trunk/admin/themes/default/template/photos_add_settings.tpl	(revision 8227)
@@ -2,10 +2,38 @@
 <script type="text/javascript">
 $(document).ready(function(){
-  function toggleResizeFields() {
-    var checkbox = $("#websize_resize");
-    var needToggle = $("input[name^=websize_]").not(checkbox).parents('tr');
+  function toggleResizeFields(prefix) {
+    var checkbox = $("#"+prefix+"_resize");
+    var needToggle = $("input[name^="+prefix+"_]").not(checkbox).not($("#hd_keep")).parents('tr');
+
 
     if ($(checkbox).is(':checked')) {
       needToggle.show();
+
+      if (prefix == "websize") {
+        $("#hd_keep").parents("fieldset").show();
+      }
+    }
+    else {
+      needToggle.hide();
+
+      if (prefix == "websize") {
+        $("#hd_keep").parents("fieldset").hide();
+      }
+    }
+  }
+
+  toggleResizeFields("websize");
+  $("#websize_resize").click(function () {toggleResizeFields("websize")});
+
+  toggleResizeFields("hd");
+  $("#hd_resize").click(function () {toggleResizeFields("hd")});
+
+  function toggleHdFields() {
+    var checkbox = $("#hd_keep");
+    var needToggle = $("input[name^=hd_]").not(checkbox).parents('tr');
+
+    if ($(checkbox).is(':checked')) {
+      needToggle.show();
+      toggleResizeFields("hd");
     }
     else {
@@ -14,6 +42,6 @@
   }
 
-  toggleResizeFields();
-  $("#websize_resize").click(function () {toggleResizeFields()});
+  toggleHdFields();
+  $("#hd_keep").click(function () {toggleHdFields()});
 });
 </script>
@@ -70,4 +98,33 @@
   </fieldset>
 
+{if $MANAGE_HD}
+  <fieldset>
+    <legend>{'High definition'|@translate}</legend>
+
+    <table>
+      <tr>
+        <th><label for="hd_keep">{'Keep high definition'|@translate}</label></th>
+        <td><input type="checkbox" name="hd_keep" id="hd_keep" {$values.hd_keep}></td>
+      </tr>
+      <tr>
+        <th><label for="hd_resize">{'Resize'|@translate}</label></th>
+        <td><input type="checkbox" name="hd_resize" id="hd_resize" {$values.hd_resize}></td>
+      </tr>
+      <tr>
+        <th>{'Maximum Width'|@translate}</th>
+        <td><input type="text" name="hd_maxwidth" value="{$values.hd_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td>
+      </tr>
+      <tr>
+        <th>{'Maximum Height'|@translate}</th>
+        <td><input type="text" name="hd_maxheight" value="{$values.hd_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td>
+      </tr>
+      <tr>
+        <th>{'Image Quality'|@translate}</th>
+        <td><input type="text" name="hd_quality" value="{$values.hd_quality}" size="3" maxlength="3"> %</td>
+      </tr>
+    </table>
+  </fieldset>
+{/if}
+
   <p>
     <input class="submit" type="submit" name="submit" value="{'Save Settings'|@translate}"/>
Index: /trunk/language/en_UK/admin.lang.php
===================================================================
--- /trunk/language/en_UK/admin.lang.php	(revision 8226)
+++ /trunk/language/en_UK/admin.lang.php	(revision 8227)
@@ -765,3 +765,8 @@
 $lang['manual order'] = 'manual order';
 $lang['Albums automatically sorted'] = 'Albums automatically sorted';
+
+$lang['Keep high definition'] = 'Keep high definition';
+$lang['The high definition maximum width must be a number between %d and %d'] = 'The high definition maximum width must be a number between %d and %d';
+$lang['The high definition maximum height must be a number between %d and %d'] = 'The high definition maximum height must be a number between %d and %d';
+$lang['The high definition image quality must be a number between %d and %d'] = 'The high definition image quality must be a number between %d and %d';
 ?>
Index: /trunk/language/fr_FR/admin.lang.php
===================================================================
--- /trunk/language/fr_FR/admin.lang.php	(revision 8226)
+++ /trunk/language/fr_FR/admin.lang.php	(revision 8227)
@@ -770,3 +770,8 @@
 $lang['manual order'] = 'ordre manuel';
 $lang['Albums automatically sorted'] = 'Les catégories ont été triées automatiquement';
+
+$lang['Keep high definition'] = 'Conserver la haute définition';
+$lang['The high definition maximum width must be a number between %d and %d'] = 'La largeur maximum pour la haute définition doit être un chiffre compris entre %d et %d';
+$lang['The high definition maximum height must be a number between %d and %d'] = 'La hauteur maximum pour la haute définition doit être un chiffre compris entre %d et %d';
+$lang['The high definition image quality must be a number between %d and %d'] = 'La qualité d\'image pour la haute définition doit être un chiffre compris entre %d et %d';
 ?>
