Changeset 8227


Ignore:
Timestamp:
Dec 22, 2010, 4:15:35 PM (10 years ago)
Author:
plg
Message:

feature 2077 added: when ImageMagick is active, ability to remove or resize
the high definition version of the photo.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions_upload.inc.php

    r8219 r8227  
    8585      false
    8686      );
     87
     88    if (is_imagick())
     89    {
     90      if ($conf['upload_form_hd_keep'])
     91      {
     92        $need_resize = need_resize($high_path, $conf['upload_form_hd_maxwidth'], $conf['upload_form_hd_maxheight']);
     93       
     94        if ($conf['upload_form_hd_resize'] and $need_resize)
     95        {
     96          pwg_image_resize(
     97            false,
     98            $high_path,
     99            $high_path,
     100            $conf['upload_form_hd_maxwidth'],
     101            $conf['upload_form_hd_maxheight'],
     102            $conf['upload_form_hd_quality'],
     103            false
     104            );
     105          $high_infos = pwg_image_infos($high_path);
     106        }
     107      }
     108      else
     109      {
     110        unlink($high_path);
     111        $high_infos = null;
     112      }
     113    }
    87114  }
    88115
     
    251278  }
    252279
    253   if (extension_loaded('imagick'))
     280  if (is_imagick())
    254281  {
    255282    return pwg_image_resize_im($source_filepath, $destination_filepath, $max_width, $max_height, $quality, $strip_metadata);
     
    521548  array_push($_SESSION['uploads_error'][$upload_id], $error_message);
    522549}
     550
     551function is_imagick()
     552{
     553  if (extension_loaded('imagick'))
     554  {
     555    return true;
     556  }
     557
     558  return false;
     559}
    523560?>
  • trunk/admin/photos_add.php

    r6365 r8227  
    104104    'error_message' => l10n('The thumbnail image quality must be a number between %d and %d'),
    105105    ),
     106 
     107  'hd_keep' => array(
     108    'default' => true,
     109    'can_be_null' => false,
     110    ),
     111 
     112  'hd_resize' => array(
     113    'default' => false,
     114    'can_be_null' => false,
     115    ),
     116 
     117  'hd_maxwidth' => array(
     118    'default' => 2000,
     119    'min' => 500,
     120    'max' => 20000,
     121    'pattern' => '/^\d+$/',
     122    'can_be_null' => false,
     123    'error_message' => l10n('The high definition maximum width must be a number between %d and %d'),
     124    ),
     125 
     126  'hd_maxheight' => array(
     127    'default' => 2000,
     128    'min' => 500,
     129    'max' => 20000,
     130    'pattern' => '/^\d+$/',
     131    'can_be_null' => false,
     132    'error_message' => l10n('The high definition maximum height must be a number between %d and %d'),
     133    ),
     134 
     135  'hd_quality' => array(
     136    'default' => 95,
     137    'min' => 50,
     138    'max' => 100,
     139    'pattern' => '/^\d+$/',
     140    'can_be_null' => false,
     141    'error_message' => l10n('The high definition image quality must be a number between %d and %d'),
     142    ),
    106143  );
    107144
  • trunk/admin/photos_add_settings.php

    r6363 r8227  
    4646  // settings
    4747  $field = 'websize_resize';
     48  $fields[] = $field;
    4849 
    49   if (empty($_POST[$field]))
    50   {
    51     $value = false;
    52   }
    53   else
     50  if (!empty($_POST[$field]))
    5451  {
    5552    $fields[] = 'websize_maxwidth';
    5653    $fields[] = 'websize_maxheight';
    5754    $fields[] = 'websize_quality';
     55  }
    5856
    59     $value = true;
     57  // hd_keep
     58  $field = 'hd_keep';
     59  $fields[] = $field;
     60 
     61  if (!empty($_POST[$field]))
     62  {
     63    $field = 'hd_resize';
     64    $fields[] = $field;
     65   
     66    if (!empty($_POST[$field]))
     67    {
     68      $fields[] = 'hd_maxwidth';
     69      $fields[] = 'hd_maxheight';
     70      $fields[] = 'hd_quality';
     71    }
    6072  }
    6173 
    62   $updates[] = array(
    63     'param' => 'upload_form_'.$field,
    64     'value' => boolean_to_string($value),
    65     );
    66   $form_values[$field] = $value;;
    67 
    6874  // and now other fields, processed in a generic way
    6975  $fields[] = 'thumb_maxwidth';
     
    7884      $value = $_POST[$field];
    7985    }
    80     $form_values[$field] = $value;
    8186   
    82     if ($upload_form_config[$field]['can_be_null'] and empty($value))
     87    if (is_bool($upload_form_config[$field]['default']))
     88    {
     89      if (isset($value))
     90      {
     91        $value = true;
     92      }
     93      else
     94      {
     95        $value = false;
     96      }
     97
     98      $updates[] = array(
     99        'param' => 'upload_form_'.$field,
     100        'value' => boolean_to_string($value)
     101        );
     102    }
     103    elseif ($upload_form_config[$field]['can_be_null'] and empty($value))
    83104    {
    84105      $updates[] = array(
     
    112133      }
    113134    }
     135   
     136    $form_values[$field] = $value;
    114137  }
    115138
     
    136159// +-----------------------------------------------------------------------+
    137160
    138 // specific case, "websize_resize" is a checkbox
    139 $field = 'websize_resize';
    140 $form_values[$field] = $form_values[$field] ? 'checked="checked"' : '';
     161foreach (array_keys($upload_form_config) as $field)
     162{
     163  if (is_bool($upload_form_config[$field]['default']))
     164  {
     165    $form_values[$field] = $form_values[$field] ? 'checked="checked"' : '';
     166  }
     167}
    141168
    142169$template->assign(
    143170    array(
    144171      'F_ADD_ACTION'=> PHOTOS_ADD_BASE_URL,
     172      'MANAGE_HD' => is_imagick(),
    145173      'values' => $form_values
    146174    )
  • trunk/admin/themes/default/template/photos_add_settings.tpl

    r6363 r8227  
    22<script type="text/javascript">
    33$(document).ready(function(){
    4   function toggleResizeFields() {
    5     var checkbox = $("#websize_resize");
    6     var needToggle = $("input[name^=websize_]").not(checkbox).parents('tr');
     4  function toggleResizeFields(prefix) {
     5    var checkbox = $("#"+prefix+"_resize");
     6    var needToggle = $("input[name^="+prefix+"_]").not(checkbox).not($("#hd_keep")).parents('tr');
     7
    78
    89    if ($(checkbox).is(':checked')) {
    910      needToggle.show();
     11
     12      if (prefix == "websize") {
     13        $("#hd_keep").parents("fieldset").show();
     14      }
     15    }
     16    else {
     17      needToggle.hide();
     18
     19      if (prefix == "websize") {
     20        $("#hd_keep").parents("fieldset").hide();
     21      }
     22    }
     23  }
     24
     25  toggleResizeFields("websize");
     26  $("#websize_resize").click(function () {toggleResizeFields("websize")});
     27
     28  toggleResizeFields("hd");
     29  $("#hd_resize").click(function () {toggleResizeFields("hd")});
     30
     31  function toggleHdFields() {
     32    var checkbox = $("#hd_keep");
     33    var needToggle = $("input[name^=hd_]").not(checkbox).parents('tr');
     34
     35    if ($(checkbox).is(':checked')) {
     36      needToggle.show();
     37      toggleResizeFields("hd");
    1038    }
    1139    else {
     
    1442  }
    1543
    16   toggleResizeFields();
    17   $("#websize_resize").click(function () {toggleResizeFields()});
     44  toggleHdFields();
     45  $("#hd_keep").click(function () {toggleHdFields()});
    1846});
    1947</script>
     
    7098  </fieldset>
    7199
     100{if $MANAGE_HD}
     101  <fieldset>
     102    <legend>{'High definition'|@translate}</legend>
     103
     104    <table>
     105      <tr>
     106        <th><label for="hd_keep">{'Keep high definition'|@translate}</label></th>
     107        <td><input type="checkbox" name="hd_keep" id="hd_keep" {$values.hd_keep}></td>
     108      </tr>
     109      <tr>
     110        <th><label for="hd_resize">{'Resize'|@translate}</label></th>
     111        <td><input type="checkbox" name="hd_resize" id="hd_resize" {$values.hd_resize}></td>
     112      </tr>
     113      <tr>
     114        <th>{'Maximum Width'|@translate}</th>
     115        <td><input type="text" name="hd_maxwidth" value="{$values.hd_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td>
     116      </tr>
     117      <tr>
     118        <th>{'Maximum Height'|@translate}</th>
     119        <td><input type="text" name="hd_maxheight" value="{$values.hd_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td>
     120      </tr>
     121      <tr>
     122        <th>{'Image Quality'|@translate}</th>
     123        <td><input type="text" name="hd_quality" value="{$values.hd_quality}" size="3" maxlength="3"> %</td>
     124      </tr>
     125    </table>
     126  </fieldset>
     127{/if}
     128
    72129  <p>
    73130    <input class="submit" type="submit" name="submit" value="{'Save Settings'|@translate}"/>
  • trunk/language/en_UK/admin.lang.php

    r8129 r8227  
    765765$lang['manual order'] = 'manual order';
    766766$lang['Albums automatically sorted'] = 'Albums automatically sorted';
     767
     768$lang['Keep high definition'] = 'Keep high definition';
     769$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';
     770$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';
     771$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';
    767772?>
  • trunk/language/fr_FR/admin.lang.php

    r8129 r8227  
    770770$lang['manual order'] = 'ordre manuel';
    771771$lang['Albums automatically sorted'] = 'Les catégories ont été triées automatiquement';
     772
     773$lang['Keep high definition'] = 'Conserver la haute définition';
     774$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';
     775$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';
     776$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';
    772777?>
Note: See TracChangeset for help on using the changeset viewer.