Changeset 17231


Ignore:
Timestamp:
07/30/12 22:03:14 (7 years ago)
Author:
rvelices
Message:

merge -r17229-17230 from trunk to branch 2.4
bug 2712: Custom sized derivatives are never sharpened
bug 2711: Watermark is sometimes applied while it should not be

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.4/i.php

    r16990 r17231  
    284284{ 
    285285  global $page; 
     286  $original_size = null; 
     287  if (isset($page['original_size'])) 
     288  { 
     289    $original_size = $page['original_size']; 
     290    if ($page['rotation_angle']==90 || $page['rotation_angle']==270) 
     291    { 
     292      $tmp = $original_size[0]; 
     293      $original_size[0] = $original_size[1]; 
     294      $original_size[1] = $tmp; 
     295    } 
     296  } 
     297 
     298  $use_watermark = $params->use_watermark; 
     299  if ($use_watermark) 
     300  { 
     301    if (!isset($original_size)) 
     302      return false; // cannot really know if a watermark is required 
     303    $dsize = $params->compute_final_size($original_size); 
     304    $use_watermark = $params->will_watermark($dsize); 
     305    ilog($use_watermark, $dsize); 
     306  } 
     307 
    286308  $candidates = array(); 
    287309  foreach(ImageStdParams::get_defined_type_map() as $candidate) 
     
    289311    if ($candidate->type == $params->type) 
    290312      continue; 
    291     if ($candidate->use_watermark != $params->use_watermark) 
     313    if ($candidate->use_watermark != $use_watermark) 
    292314      continue; 
    293315    if ($candidate->max_width() < $params->max_width() || $candidate->max_height() < $params->max_height()) 
     
    302324      if ($candidate->sizing->max_crop!=0) 
    303325        continue; // this could be optimized 
    304       if (!isset($page['original_size'])) 
     326      if (!isset($original_size)) 
    305327        continue; 
    306       $candidate_size = $candidate->compute_final_size($page['original_size']); 
     328      $candidate_size = $candidate->compute_final_size($original_size); 
    307329      if ($candidate_size[0] < $params->sizing->min_size[0] || $candidate_size[1] < $params->sizing->min_size[1] ) 
    308330        continue; 
     
    325347    $page['src_url'] = $page['root_path'] . substr($candidate_path, strlen(PHPWG_ROOT_PATH)); 
    326348    $page['rotation_angle'] = 0; 
    327   } 
     349                return true; 
     350  } 
     351        return false; 
    328352} 
    329353 
     
    477501        $page['rotation_angle'] = pwg_image::get_rotation_angle_from_code($row['rotation']); 
    478502      } 
    479  
    480503    } 
    481504    if (!$row) 
     
    495518mysql_close($pwg_db_link); 
    496519 
    497 try_switch_source($params, $src_mtime); 
     520if (!try_switch_source($params, $src_mtime) && $params->type==IMG_CUSTOM) 
     521{ 
     522        $sharpen = 0; 
     523        foreach (ImageStdParams::get_defined_type_map() as $std_params) 
     524        { 
     525                $sharpen += $std_params->sharpen; 
     526        } 
     527        $params->sharpen = round($sharpen / count(ImageStdParams::get_defined_type_map()) ); 
     528} 
    498529 
    499530if (!mkgetdir(dirname($page['derivative_path']))) 
Note: See TracChangeset for help on using the changeset viewer.