Changeset 14649


Ignore:
Timestamp:
May 2, 2012, 6:29:56 AM (12 years ago)
Author:
rvelices
Message:

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)
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/configuration.php

    r14513 r14649  
    455455      }
    456456
    457       $common_quality = 50;
    458 
    459457      $tpl_vars = array();
    460458      foreach(ImageStdParams::get_all_types() as $type)
     
    487485          }
    488486          $tpl_var['sharpen'] = $params->sharpen;
    489           $tpl_var['quality'] = $params->quality;
    490          
    491           if ($params->quality > $common_quality and $tpl_var['enabled'])
    492           {
    493             $common_quality = $params->quality;
    494           }
    495487        }
    496488        $tpl_vars[$type]=$tpl_var;
    497489      }
    498490      $template->assign('derivatives', $tpl_vars);
    499       $template->assign('resize_quality', $common_quality);
     491      $template->assign('resize_quality', ImageStdParams::$quality);
    500492    }
    501493
  • trunk/admin/include/configuration_sizes_process.inc.php

    r14221 r14649  
    9898      $errors[$type]['w'] = '>0';
    9999    }
    100    
     100
    101101    $h = intval($pderivative['h']);
    102102    if ($h <= 0)
     
    104104      $errors[$type]['h'] = '>0';
    105105    }
    106    
     106
    107107    if (max($w,$h) <= $prev_w)
    108108    {
     
    117117      $errors[$type]['w'] = '>'.$prev_w;
    118118    }
    119    
     119
    120120    $v = intval($pderivative['h']);
    121121    if ($v <= 0 or $v <= $prev_h)
     
    124124    }
    125125  }
    126  
     126
    127127  if (count($errors) == 0)
    128128  {
     
    130130    $prev_h = intval($pderivative['h']);
    131131  }
     132
     133  $v = intval($pderivative['sharpen']);
     134  if ($v<0 || $v>100)
     135  {
     136    $errors[$type]['sharpen'] = '[0..100]';
     137  }
    132138}
    133139
     
    135141if (count($errors) == 0)
    136142{
     143  $quality_changed = ImageStdParams::$quality != intval($_POST['resize_quality']);
     144  ImageStdParams::$quality = intval($_POST['resize_quality']);
     145
    137146  $enabled = ImageStdParams::get_defined_type_map();
    138147  $disabled = @unserialize( @$conf['disabled_derivatives'] );
     
    146155  {
    147156    $pderivative = $pderivatives[$type];
    148    
     157
    149158    if ($pderivative['enabled'])
    150159    {
     
    156165          )
    157166        );
    158      
    159       $new_params->quality = intval($_POST['resize_quality']);
    160      
     167      $new_params->sharpen = intval($pderivative['sharpen']);
     168
    161169      ImageStdParams::apply_global($new_params);
    162      
     170
    163171      if (isset($enabled[$type]))
    164172      {
     
    170178          $same = false;
    171179        }
    172        
     180
    173181        if ($same
    174182            and $new_params->sizing->max_crop != 0
     
    177185          $same = false;
    178186        }
    179        
    180         if ($new_params->quality != $old_params->quality)
     187
     188        if ($quality_changed
     189            || $new_params->sharpen != $old_params->sharpen)
    181190        {
    182191          $same = false;
    183192        }
    184        
     193
    185194        if (!$same)
    186195        {
     
    210219    }
    211220  }
    212  
     221
    213222  $enabled_by = array(); // keys ordered by all types
    214223  foreach(ImageStdParams::get_all_types() as $type)
     
    219228    }
    220229  }
    221  
     230
    222231  ImageStdParams::set_and_save($enabled_by);
    223232  if (count($disabled) == 0)
     
    231240  }
    232241  $conf['disabled_derivatives'] = serialize($disabled);
    233  
     242
    234243  if (count($changed_types))
    235244  {
    236245    clear_derivative_cache($changed_types);
    237246  }
    238  
     247
    239248  array_push(
    240249    $page['infos'],
     
    257266    }
    258267  }
    259  
     268
    260269  $template->assign('derivatives', $pderivatives);
    261270  $template->assign('ferrors', $errors);
  • trunk/admin/include/image.class.php

    r13882 r14649  
    288288  static function get_sharpen_matrix($amount)
    289289  {
    290     // Amount should be in the range of 28-10
    291     $amount = round(abs(-28 + ($amount * 0.18)), 2);
     290    // Amount should be in the range of 48-10
     291    $amount = round(abs(-48 + ($amount * 0.38)), 2);
    292292
    293293    $matrix = array(
     
    550550  function rotate($rotation)
    551551  {
     552    if ($rotation==90 || $rotation==270)
     553    {
     554      $tmp = $this->width;
     555      $this->width = $this->height;
     556      $this->height = $tmp;
     557    }
    552558    $this->add_command('rotate', -$rotation);
    553559    $this->add_command('orient', 'top-left');
     
    563569  function resize($width, $height)
    564570  {
    565     $this->add_command('interlace', 'line');
    566571    $this->add_command('filter', 'Lanczos');
    567572    $this->add_command('resize', $width.'x'.$height.'!');
     
    596601  function write($destination_filepath)
    597602  {
     603    $this->add_command('interlace', 'line'); // progressive rendering
     604
    598605    $exec = $this->imagickdir.'convert';
    599606    $exec .= ' "'.realpath($this->source_filepath).'"';
     
    612619    @exec($exec, $returnarray);
    613620
    614     //echo($exec);
     621    ilog($exec);
     622    if (is_array($returnarray) && (count($returnarray)>0) )
     623    {
     624      ilog($returnarray);
     625    }
    615626    return is_array($returnarray);
    616627  }
  • trunk/admin/themes/default/template/configuration.tpl

    r14548 r14649  
    432432        </tr>
    433433  {/if}
     434                                <tr>
     435                                <td>{'Sharpen'|@translate}</td>
     436                                <td>
     437                                        <input type="text" name="d[{$type}][sharpen]" maxlength="4" size="4"  value="{$d.sharpen}"{if isset($ferrors.$type.sharpen)} class="dError"{/if}>
     438                                        %
     439                                        {if isset($ferrors.$type.sharpen)}<span class="dErrorDesc" title="{$ferrors.$type.sharpen}">!</span>{/if}
     440                                </td>
     441                                </tr>
    434442      </table> {* #sizeEdit *}
    435443    </td>
  • trunk/i.php

    r13864 r14649  
    583583}
    584584
    585 $image->set_compression_quality( $params->quality );
     585$image->set_compression_quality( ImageStdParams::$quality );
    586586$image->write( $page['derivative_path'] );
    587587$image->destroy();
  • trunk/include/derivative_params.inc.php

    r14221 r14649  
    241241  public $sizing;
    242242  public $sharpen = 0;
    243   public $quality = 95;
    244243
    245244  function __construct($sizing)
     
    250249  public function __sleep()
    251250  {
    252       return array('last_mod_time', 'sizing', 'sharpen', 'quality');
     251      return array('last_mod_time', 'sizing', 'sharpen');
    253252  }
    254253
  • trunk/include/derivative_std_params.inc.php

    r14581 r14649  
    5252  private static $watermark;
    5353  public static $custom = array();
     54  public static $quality=95;
    5455
    5556  static function get_all_types()
     
    110111      self::$custom = @$arr['c'];
    111112      if (!self::$custom) self::$custom = array();
     113      if (isset($arr['q'])) self::$quality = $arr['q'];
    112114    }
    113115    else
     
    115117      self::$watermark = new WatermarkParams();
    116118      self::$type_map = self::get_default_sizes();
     119      self::save();
    117120    }
    118121    self::build_maps();
     
    137140    $ser = serialize( array(
    138141      'd' => self::$type_map,
     142      'q' => self::$quality,
    139143      'w' => self::$watermark,
    140144      'c' => self::$custom,
  • trunk/language/en_UK/admin.lang.php

    r14648 r14649  
    918918$lang['%d second'] = '%d second';
    919919$lang['%d seconds'] = '%d seconds';
     920$lang['Sharpen'] = 'Sharpen';
    920921?>
Note: See TracChangeset for help on using the changeset viewer.