PX : code

Image Reduction by Morgan Everett
Download this code


<?php 

function imagereduction($imagepath) {
        
// Returns an associative array with height and width attributes of
        // Of a resized image.
        // picsize variable control the maximum size of the height/width
        // Function keeps proportions the same 
        
$picsize 320;

        
$size getimagesize($imagepath);
        
$dim[height] = $size[1]; $dim[width] = $size[0];

        while(
$dim[width] > $picsize){
                
$dim[width] = $dim[width] * .5;
                
$widthreduce++; }
        for(
$heightreduce 0$heightreduce $widthreduce$heightreduce++){
                
$dim[height] = $dim[height] * .5;}
        while(
$dim[height] > $picsize){
                
$dim[height] = $dim[height] * .5;
                
$heightreduce++; }
        for(
$widthreduce=$widthreduce$widthreduce $heightreduce$widthreduce++){
                
$dim[width] = $dim[width] * .5;}

        
$dim[height] = (int)$dim[height]; $dim[width] = (int)$dim[width];

        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.