<?php
header("content-type:text/html;charset=utf-8");
$img=$_REQUEST["img"];
$aimg=$_REQUEST["aimg"]?:$img;
$width=$_REQUEST["width"];
$height=$_REQUEST["height"];
function img($img,$width,$height,$aimg)
{
$imgage=getimagesize($img);
switch($imgage[2])
{
case 1:
$im=imagecreatefromgif($img);
break;
case 2:
$im=imagecreatefromjpeg($img);
break;
case 3:
$im=imagecreatefrompng($img);
break;
}
$srcw=$imgage[0];
$srch=$imgage[1];
$bimg=imagecreatetruecolor($width,$height);
imagecopyresampled($bimg,$im,0,0,0,0,$width,$height,$srcw,$srch);
imagejpeg($bimg,$aimg);
}
img($img,$width,$height,$aimg);
?>