PX : code

image resize function by Sutat Surakul
Download this code


<?php
function imgreduce($imagepath,$picsize

        
$size getimagesize($imagepath); 
        
$dim[height] = $size[1];
        
$dim[width] = $size[0]; 
$ratio_width $dim[width] / $picsize;
    
$ratio_height $dim[height] / $picsize;
    if(
$picsize >= $dim[width] && $picsize >= $dim[height])
    {
        return 
$dim;
    }
    if (
$ratio_width $ratio_height)
    {
        
$new_width = (int)$picsize;
        
$new_height = (int)($dim[height] * $picsize $dim[width]);
    }else{
        
$new_height = (int)$picsize;
        
$new_width = (int)($dim[width] * $picsize $dim[height]);
    }
    
$dim[width] = $new_width;
    
$dim[height] = $new_height;
    return 
$dim
}

?>

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.