Witam chciałbym ,żeby zdjęcie dodawane na serwer przez użytkownika było przerabiane do wymiaru:
y-150px
x-150px.
function resize2($filef, $new_width, $new_height, $thumb, $quality) { if ($info === false) return false; $img = null; switch($info[2]){ case IMAGETYPE_JPEG: $img = imagecreatefromjpeg($filef); break; case IMAGETYPE_GIF: $img = imagecreatefromgif($filef); break; case IMAGETYPE_PNG: $img = imagecreatefrompng($filef); break; default: return false; } $th = imagecreatetruecolor(150, 150); switch($info[2]){ case IMAGETYPE_JPEG: imagecopyresampled($th, $img, 0, 0, 0, 0, $new_width, $new_height, $info[0], $info[1]); imagejpeg($th, $filef, $quality); break; case IMAGETYPE_GIF: imagealphablending($th, true); imagetruecolortopalette($img, true, 256); imagecopyresampled($th, $img, 0, 0, 0, 0, $new_width, $new_height, $info[0], $info[1]); imagegif($th, $filef); break; case IMAGETYPE_PNG: imagealphablending($th, false); imagesavealpha($th, true); imagecopyresampled($th, $img, 0, 0, 0, 0, $new_width, $new_height, $info[0], $info[1]); imagepng($th, $filef); break; } imagedestroy($th); imagedestroy($img); return true; }
.
$plik_tmp = $_FILES['zdjecie']['tmp_name'];