Mam skrypt, wrzucam, zmniejsza mi ale nie dostosowuje szerokości mam tylko mały prostokąt, co jest nie tak?ustawiłem na sztywno maxy i dalej nic.
<?php
if(isset($_POST['submit'])) {
$allowed = array ('image/pjpeg', 'image/JPEG', 'image/JPG', 'image/jpeg', 'image/jpg', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png', 'image/gif'); if(in_array($_FILES['userfile']['type'],$allowed)) {
$url='../rsah/upload/';
$turl='../rsah/thumb/';
$tmpName=$_FILES['userfile']['tmp_name'];
$name=$_FILES['userfile']['name'];
//do miniaturek
switch($sType)
{
case IMAGETYPE_GIF:
$gType=imagecreatefromgif($tmpName);
break;
case IMAGETYPE_PNG:
$gType=imagecreatefrompng($tmpName);
break;
case IMAGETYPE_JPEG:
$gType=imagecreatefromjpeg($tmpName);
break;
default:
}
$sourceRatio=$sWidth/$sHeight;
$thumbnailRatio=$maxWidth/$maxHeight;
if($sWidth<=$maxWidth && $sHeight<=$maxHeight)
{
$tWidth=$sWidth;
$tHeight=$sHeight;
}
else if ($thumbnailRatio>$sourceRatio)
{
$tWidth= (int) ($maxHeight * $sourceRatio);
$tHeight= $maxHeight;
}
else
{
$tWidth= $maxWidth;
$tHeight= (int) ($maxWidth/$sourceRatio);
}
$thumbnailImage=imagecreatetruecolor($tWidth,$tHeight);
imagecopyresampled($thumbnailImage,$gType,0,0,0,0,$maxWidth,$maxHeight,$sWidth,$sHeight);
imagejpeg($thumbnailImage,$turl.$name,90);
imagedestroy($gType);
imagedestroy($thumbnailImage);
}
else
{
echo $_FILES['userfile']['tmp_name']; echo $_FILES['userfile']['name']; echo $_FILES['userfile']['type']; }
}
else
{
}
?>