diff options
Diffstat (limited to 'admin')
-rw-r--r-- | admin/configuration.php | 10 | ||||
-rw-r--r-- | admin/include/configuration_sizes_process.inc.php | 45 | ||||
-rw-r--r-- | admin/include/image.class.php | 19 | ||||
-rw-r--r-- | admin/themes/default/template/configuration.tpl | 8 |
4 files changed, 51 insertions, 31 deletions
diff --git a/admin/configuration.php b/admin/configuration.php index f9e0999e8..60da0ae0e 100644 --- a/admin/configuration.php +++ b/admin/configuration.php @@ -454,8 +454,6 @@ switch ($page['section']) $disabled = array(); } - $common_quality = 50; - $tpl_vars = array(); foreach(ImageStdParams::get_all_types() as $type) { @@ -486,17 +484,11 @@ switch ($page['section']) $tpl_var['minw'] = $tpl_var['minh'] = ""; } $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); } break; diff --git a/admin/include/configuration_sizes_process.inc.php b/admin/include/configuration_sizes_process.inc.php index 603103fe1..31153f16b 100644 --- a/admin/include/configuration_sizes_process.inc.php +++ b/admin/include/configuration_sizes_process.inc.php @@ -97,13 +97,13 @@ foreach(ImageStdParams::get_all_types() as $type) { $errors[$type]['w'] = '>0'; } - + $h = intval($pderivative['h']); if ($h <= 0) { $errors[$type]['h'] = '>0'; } - + if (max($w,$h) <= $prev_w) { $errors[$type]['w'] = $errors[$type]['h'] = '>'.$prev_w; @@ -116,24 +116,33 @@ foreach(ImageStdParams::get_all_types() as $type) { $errors[$type]['w'] = '>'.$prev_w; } - + $v = intval($pderivative['h']); if ($v <= 0 or $v <= $prev_h) { $errors[$type]['h'] = '>'.$prev_h; } } - + if (count($errors) == 0) { $prev_w = intval($pderivative['w']); $prev_h = intval($pderivative['h']); } + + $v = intval($pderivative['sharpen']); + if ($v<0 || $v>100) + { + $errors[$type]['sharpen'] = '[0..100]'; + } } // step 3 - save data 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'] ); if ($disabled === false) @@ -145,7 +154,7 @@ if (count($errors) == 0) foreach (ImageStdParams::get_all_types() as $type) { $pderivative = $pderivatives[$type]; - + if ($pderivative['enabled']) { $new_params = new DerivativeParams( @@ -155,11 +164,10 @@ if (count($errors) == 0) array(intval($pderivative['minw']), intval($pderivative['minh'])) ) ); - - $new_params->quality = intval($_POST['resize_quality']); - + $new_params->sharpen = intval($pderivative['sharpen']); + ImageStdParams::apply_global($new_params); - + if (isset($enabled[$type])) { $old_params = $enabled[$type]; @@ -169,19 +177,20 @@ if (count($errors) == 0) { $same = false; } - + if ($same and $new_params->sizing->max_crop != 0 and !size_equals($old_params->sizing->min_size, $new_params->sizing->min_size)) { $same = false; } - - if ($new_params->quality != $old_params->quality) + + if ($quality_changed + || $new_params->sharpen != $old_params->sharpen) { $same = false; } - + if (!$same) { $new_params->last_mod_time = time(); @@ -209,7 +218,7 @@ if (count($errors) == 0) } } } - + $enabled_by = array(); // keys ordered by all types foreach(ImageStdParams::get_all_types() as $type) { @@ -218,7 +227,7 @@ if (count($errors) == 0) $enabled_by[$type] = $enabled[$type]; } } - + ImageStdParams::set_and_save($enabled_by); if (count($disabled) == 0) { @@ -230,12 +239,12 @@ if (count($errors) == 0) conf_update_param('disabled_derivatives', addslashes(serialize($disabled)) ); } $conf['disabled_derivatives'] = serialize($disabled); - + if (count($changed_types)) { clear_derivative_cache($changed_types); } - + array_push( $page['infos'], l10n('Your configuration settings are saved') @@ -256,7 +265,7 @@ else ); } } - + $template->assign('derivatives', $pderivatives); $template->assign('ferrors', $errors); $template->assign('resize_quality', $_POST['resize_quality']); diff --git a/admin/include/image.class.php b/admin/include/image.class.php index 062341913..53516f62d 100644 --- a/admin/include/image.class.php +++ b/admin/include/image.class.php @@ -287,8 +287,8 @@ class pwg_image /** Returns a normalized convolution kernel for sharpening*/ 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( array(-1, -1, -1), @@ -549,6 +549,12 @@ class image_ext_imagick implements imageInterface 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'); return true; @@ -562,7 +568,6 @@ class image_ext_imagick implements imageInterface function resize($width, $height) { - $this->add_command('interlace', 'line'); $this->add_command('filter', 'Lanczos'); $this->add_command('resize', $width.'x'.$height.'!'); return true; @@ -595,6 +600,8 @@ class image_ext_imagick implements imageInterface function write($destination_filepath) { + $this->add_command('interlace', 'line'); // progressive rendering + $exec = $this->imagickdir.'convert'; $exec .= ' "'.realpath($this->source_filepath).'"'; @@ -611,7 +618,11 @@ class image_ext_imagick implements imageInterface $exec .= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'"'; @exec($exec, $returnarray); - //echo($exec); + ilog($exec); + if (is_array($returnarray) && (count($returnarray)>0) ) + { + ilog($returnarray); + } return is_array($returnarray); } } diff --git a/admin/themes/default/template/configuration.tpl b/admin/themes/default/template/configuration.tpl index bdd7a7a28..3c87f1186 100644 --- a/admin/themes/default/template/configuration.tpl +++ b/admin/themes/default/template/configuration.tpl @@ -431,6 +431,14 @@ jQuery(document).ready(function(){ </td> </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> </tr> |