multi size:

- fix external imagick issues when rotation was required
- fix: derivative were generated continuosly until a first save performed in the admin screen
- added sharpen param in the new config screen
- increased the sharpen range (10% is less than before)

git-svn-id: http://piwigo.org/svn/trunk@14649 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices 2012-05-02 04:29:56 +00:00
parent 642d757bd4
commit 40a4dd63f0
8 changed files with 58 additions and 34 deletions

View file

@ -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;

View file

@ -129,11 +129,20 @@ foreach(ImageStdParams::get_all_types() as $type)
$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)
@ -155,8 +164,7 @@ 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);
@ -177,7 +185,8 @@ if (count($errors) == 0)
$same = false;
}
if ($new_params->quality != $old_params->quality)
if ($quality_changed
|| $new_params->sharpen != $old_params->sharpen)
{
$same = false;
}

View file

@ -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);
}
}

View file

@ -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>

2
i.php
View file

@ -582,7 +582,7 @@ if ($d_size[0]*$d_size[1] < 256000)
$image->strip();
}
$image->set_compression_quality( $params->quality );
$image->set_compression_quality( ImageStdParams::$quality );
$image->write( $page['derivative_path'] );
$image->destroy();
$timing['save'] = time_step($step);

View file

@ -240,7 +240,6 @@ final class DerivativeParams
public $use_watermark = false;
public $sizing;
public $sharpen = 0;
public $quality = 95;
function __construct($sizing)
{
@ -249,7 +248,7 @@ final class DerivativeParams
public function __sleep()
{
return array('last_mod_time', 'sizing', 'sharpen', 'quality');
return array('last_mod_time', 'sizing', 'sharpen');
}
function add_url_tokens(&$tokens)

View file

@ -51,6 +51,7 @@ final class ImageStdParams
private static $undefined_type_map = array();
private static $watermark;
public static $custom = array();
public static $quality=95;
static function get_all_types()
{
@ -109,11 +110,13 @@ final class ImageStdParams
if (!self::$watermark) self::$watermark = new WatermarkParams();
self::$custom = @$arr['c'];
if (!self::$custom) self::$custom = array();
if (isset($arr['q'])) self::$quality = $arr['q'];
}
else
{
self::$watermark = new WatermarkParams();
self::$type_map = self::get_default_sizes();
self::save();
}
self::build_maps();
}
@ -136,6 +139,7 @@ final class ImageStdParams
$ser = serialize( array(
'd' => self::$type_map,
'q' => self::$quality,
'w' => self::$watermark,
'c' => self::$custom,
) );

View file

@ -917,4 +917,5 @@ $lang['%d minute'] = '%d minute';
$lang['%d minutes'] = '%d minutes';
$lang['%d second'] = '%d second';
$lang['%d seconds'] = '%d seconds';
$lang['Sharpen'] = 'Sharpen';
?>