Changeset 13035 for trunk/admin


Ignore:
Timestamp:
02/05/12 15:58:14 (8 years ago)
Author:
rvelices
Message:

multisize

  • watermarks loaded also from local dir
  • fix/simplify algo for cropping
  • imagick use scaleImage (fast) before resizeImage (slow) if the original is a lot bigger than the requested size
Location:
trunk/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/derivatives.php

    r13021 r13035  
    6868      $errors[$type]['crop'] = '[0..100]'; 
    6969    } 
    70      
     70 
    7171    if ($v!=0) 
    7272    { 
     
    8282      } 
    8383    } 
    84      
     84 
    8585    if (count($errors)==0) 
    8686    { 
     
    8888      $prev_h = intval($pderivative['h']); 
    8989    } 
    90      
     90 
    9191    $v = intval($pderivative['sharpen']); 
    9292    if ($v<0 || $v>100) 
     
    127127    $watermark->opacity = intval($pwatermark['opacity']); 
    128128    $watermark->min_size = array(intval($pwatermark['minw']),intval($pwatermark['minh'])); 
    129      
     129 
    130130    $old_watermark = ImageStdParams::get_watermark(); 
    131     $watermark_changed =  
     131    $watermark_changed = 
    132132      $watermark->file != $old_watermark->file 
    133133      || $watermark->xpos != $old_watermark->xpos 
     
    136136      || $watermark->opacity != $old_watermark->opacity; 
    137137    ImageStdParams::set_watermark($watermark); 
    138      
     138 
    139139    $enabled = ImageStdParams::get_defined_type_map(); 
    140140    $disabled = @unserialize( @$conf['disabled_derivatives'] ); 
     
    144144    } 
    145145    $changed_types = array(); 
    146      
     146 
    147147    foreach(ImageStdParams::get_all_types() as $type) 
    148148    { 
    149149      $pderivative = $pderivatives[$type]; 
    150        
     150 
    151151      if ($pderivative['enabled']) 
    152152      { 
    153153        $new_params = new DerivativeParams( 
    154             new SizingParams(  
     154            new SizingParams( 
    155155              array(intval($pderivative['w']), intval($pderivative['h'])), 
    156156              round($pderivative['crop'] / 100, 2), 
    157157              array(intval($pderivative['minw']), intval($pderivative['minh'])) 
    158               )  
     158              ) 
    159159          ); 
    160160        $new_params->sharpen = intval($pderivative['sharpen']); 
    161161        $new_params->quality = intval($pderivative['quality']); 
    162162        ImageStdParams::apply_global($new_params); 
    163          
     163 
    164164        if (isset($enabled[$type])) 
    165165        { 
     
    172172          } 
    173173 
    174           if ( $same && $new_params->sizing->max_crop != 0  
     174          if ( $same && $new_params->sizing->max_crop != 0 
    175175              && !size_equals($old_params->sizing->min_size, $new_params->sizing->min_size) ) 
    176176          { 
     
    178178          } 
    179179 
    180           if ( $same &&  
     180          if ( $same && 
    181181              ( $new_params->sharpen != $old_params->sharpen 
    182182              || $new_params->quality > $old_params->quality) 
     
    185185            $same = false; 
    186186          } 
    187            
     187 
    188188          if ($same && 
    189             ( $new_params->use_watermark != $old_params->use_watermark  
     189            ( $new_params->use_watermark != $old_params->use_watermark 
    190190             || $new_params->use_watermark && $watermark_changed ) 
    191191            ) 
     
    193193            $same = false; 
    194194          } 
    195            
     195 
    196196          if (!$same) 
    197197          { 
     
    229229        $enabled_by[$type] = $enabled[$type]; 
    230230      } 
    231     }     
     231    } 
    232232    ImageStdParams::set_and_save($enabled_by); 
    233233    if (count($disabled)==0) 
     
    241241    } 
    242242    $conf['disabled_derivatives']=serialize($disabled); 
    243      
     243 
    244244    if (count($changed_types)) 
    245245    { 
     
    299299  } 
    300300  $template->assign('derivatives', $tpl_vars); 
    301    
     301 
    302302  $wm = ImageStdParams::get_watermark(); 
    303303  $template->assign('watermark', array( 
     
    317317  $watermark_files[] = substr($file, strlen(PHPWG_ROOT_PATH)); 
    318318} 
     319foreach (glob(PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'watermarks/*.png') as $file) 
     320{ 
     321  $watermark_files[] = substr($file, strlen(PHPWG_ROOT_PATH)); 
     322} 
    319323$watermark_filemap = array( '' => '---' ); 
    320324foreach( $watermark_files as $file) 
  • trunk/admin/include/image.class.php

    r12956 r13035  
    424424  { 
    425425    $this->image->setInterlaceScheme(Imagick::INTERLACE_LINE); 
     426    if ($this->get_width()%2 == 0 && $this->get_height()%2 == 0 
     427      && $this->get_width() > 3*$width) 
     428    { 
     429      $this->image->scaleImage($this->get_width()/2, $this->get_height()/2); 
     430    } 
    426431    return $this->image->resizeImage($width, $height, Imagick::FILTER_LANCZOS, 0.9); 
    427432  } 
Note: See TracChangeset for help on using the changeset viewer.