PX : code

Resize image by Mårten Andersson
Download this code


<?php
##Makes a resized temporary image 
##This script can only handle jpg and png imagetypes 
##INPUT: imagename and the size of the new image in percent.
##EXAMPLE: <img src='changeImgSize.php?userfile=image.png&procent=200'>
##The example will create a copy of the image with the double size


$pr $procent/100;
$size GetImageSize ($userfile);
if(
$size[2] == '2'){
    
$src_img imagecreatefromjpeg($userfile);
    
$headertype "jpeg";
}elseif(
$size[2] == '3'){
    
$src_img imagecreatefrompng($userfile);
    
$headertype "png";
}
$new_w imagesx($src_img)*$pr;
$new_h imagesy($src_img)*$pr;
$dst_img imagecreatetruecolor($new_w,$new_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img));
header ("Content-type: image/$headertype");
if(
$size[2] == '2'){
    
imagejpeg($dst_img);    
}elseif(
$size[2] == '3'){
    
imagepng($dst_img);
}
imagedestroy($dst_img);
?>

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.