Changeset 9755


Ignore:
Timestamp:
03/18/11 15:02:26 (9 years ago)
Author:
patdenice
Message:

Revert branch 2.1 (wrong ccommit)

Location:
extensions/square_thumbnails/branch/2.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/square_thumbnails/branch/2.1/functions.inc.php

    r9754 r9755  
    152152  } 
    153153 
    154   if (is_imagick()) 
    155   { 
    156     return pwg_image_resize_im($source_filepath, $destination_filepath, $max_width, $max_height, $quality, $strip_metadata); 
    157   } 
    158   else 
    159   { 
    160     return pwg_image_resize_gd($source_filepath, $destination_filepath, $max_width, $max_height, $quality); 
    161   } 
    162 } 
    163  
    164 function upload_square_resize_gd($result, $source_filepath, $destination_filepath, $max_width, $max_height, $quality) 
    165 { 
    166154  if (!function_exists('gd_info')) 
    167155  { 
     
    175163  if (in_array($extension, array('jpg', 'jpeg'))) 
    176164  { 
    177     $source_image = imagecreatefromjpeg($source_filepath); 
     165    $source_image = @imagecreatefromjpeg($source_filepath); 
    178166  } 
    179167  else if ($extension == 'png') 
    180168  { 
    181     $source_image = imagecreatefrompng($source_filepath); 
     169    $source_image = @imagecreatefrompng($source_filepath); 
    182170  } 
    183171  else 
    184172  { 
    185173    die('unsupported file extension'); 
    186   } 
    187  
    188   $rotation = null; 
    189   if (function_exists('imagerotate')) 
    190   { 
    191     $rotation = get_rotation_angle($source_filepath); 
    192174  } 
    193175   
     
    209191  } 
    210192   
    211   $resize_dimensions = get_resize_dimensions($source_width, $source_height, $max_width, $max_height, $rotation); 
    212  
    213   // testing on height is useless in theory: if width is unchanged, there 
    214   // should be no resize, because width/height ratio is not modified. 
    215   if ($resize_dimensions['width'] == $source_width and $resize_dimensions['height'] == $source_height) 
     193  $ratio_width  = $source_width / $max_width; 
     194  $ratio_height = $source_height / $max_height; 
     195   
     196  // maximal size exceeded ? 
     197  if ($ratio_width > 1 or $ratio_height > 1) 
     198  { 
     199    if ($ratio_width < $ratio_height) 
     200    {  
     201      $destination_width = ceil($source_width / $ratio_height); 
     202      $destination_height = $max_height;  
     203    } 
     204    else 
     205    {  
     206      $destination_width = $max_width;  
     207      $destination_height = ceil($source_height / $ratio_width); 
     208    } 
     209  } 
     210  else 
    216211  { 
    217212    // the image doesn't need any resize! We just copy it to the destination 
     
    220215  } 
    221216   
    222   $destination_image = imagecreatetruecolor($resize_dimensions['width'], $resize_dimensions['height']); 
     217  $destination_image = imagecreatetruecolor($destination_width, $destination_height); 
    223218   
    224219  imagecopyresampled( 
     
    229224    $x, 
    230225    $y, 
    231     $resize_dimensions['width'], 
    232     $resize_dimensions['height'], 
     226    $destination_width, 
     227    $destination_height, 
    233228    $source_width, 
    234229    $source_height 
    235230    ); 
    236  
    237   // rotation occurs only on resized photo to avoid useless memory use 
    238   if (isset($rotation)) 
    239   { 
    240     $destination_image = imagerotate($destination_image, $rotation, 0); 
    241   } 
    242    
    243   $extension = strtolower(get_extension($destination_filepath)); 
    244   if ($extension == 'png') 
    245   { 
    246     imagepng($destination_image, $destination_filepath); 
    247   } 
    248   else 
    249   { 
    250     imagejpeg($destination_image, $destination_filepath, $quality); 
    251   } 
     231   
     232  imagejpeg($destination_image, $destination_filepath, $quality); 
    252233  // freeing memory ressources 
    253234  imagedestroy($source_image); 
  • extensions/square_thumbnails/branch/2.1/photo_add_settings.php

    r9754 r9755  
    4343 
    4444// Template init 
    45 $template->assign('SQUARE', $conf['upload_form_thumb_square']); 
     45$template->assign('SQUARE', @$conf['upload_form_thumb_square']); 
    4646 
    4747// Add prefilter 
Note: See TracChangeset for help on using the changeset viewer.