Código PHP:
function resize ($resizeone, $resizetou, $newdimone, $newdimtou, $resizestry, $resizefor, $resizefive)
{
if ($resizefive == 2)
{
$resizeone = imagecreatefromjpeg ($resizeone);
$resizesex = imagecreatetruecolor ($resizestry, $resizefor);
imagecopyresampled ($resizesex, $resizeone, 0, 0, 0, 0, $resizestry, $resizefor, $newdimone, $newdimtou);
touch ($resizetou);
imagejpeg ($resizesex, $resizetou);
imagedestroy ($resizesex);
return null;
}
if ($resizefive == 3)
{
$resizeone = imagecreatefrompng ($resizeone);
$resizesex = imagecreatetruecolor ($resizestry, $resizefor);
imagecopyresampled ($resizesex, $resizeone, 0, 0, 0, 0, $resizestry, $resizefor, $newdimone, $newdimtou);
touch ($resizetou);
imagepng ($resizesex, $resizetou);
imagedestroy ($resizesex);
}
}