Thread: Image Uploading
View Single Post
Old 10-16-2008, 07:14 PM   #11 (permalink)
code_junkie
The Contributor
 
Join Date: Sep 2008
Posts: 39
Thanks: 9
code_junkie is on a distinguished road
Default

I got a quick question for you Wildhoney. My fried had a resize script laying around but does know how to use it. How would I implement it into the script you gave me?
PHP Code:
<?php
  $source_pic 
'images/source.jpg';
  
$destination_pic 'images/destination.jpg';
  
$max_width 200;
  
$max_height 200;
  
$src imagecreatefromjpeg($source_pic);
  list(
$width,$height) = getimagesize($source_pic);
  
$x_ratio $max_width/$width;
  
$y_ration $max_height/$height;
  
  if (
$width <= $max_width) && ($height <= $max_height)
    {
      
$tn_width $width;
      
$tn_height $height;
    }
    
  else if ((
$x_ratio*$height) < $max_height))
    {
      
$tn_height ceil($x_ratio*$height);
      
$tn_width=$max_width;
    }

  else
    {
      
$tn_height ceil($y_ration*$width);
      
$tn_height $max_height;
    }
    
  
$tmp imgcreatetruecolor ($tn_width,$tn_height);
  
imagecopyresample($tmp,$src,0,0,0,0,$tn_width,$tn_height,$width,$height);
  
imagejpeg($tmp,$destination_pic,100);
  
imagedestroy($src);
  
imagedestroy($tmp);
?>
__________________
Trying to learn all I can about PHP. Teach me what you know...
code_junkie is offline  
Reply With Quote