CODE (text):
скопировать код в буфер обмена
скопировать код в буфер обмена
- function imgResize($src, $dest, $width=200, $height=200, $quality=85) {
- if (!file_exists($src)) return false;
- ini_set('max_execution_time','600');
- $gd_ver = gd_info();
- $res = ereg_replace('[[:alpha:][:space:]()]+', '', $GDArray['GD Version']);
- if ($res >= 1.8) echo 'Error!';
- $size = getimagesize($src);
- if ($size === false) return false;
- list($width_orig, $height_orig) = getimagesize($src);
- $ratio_orig = $width_orig / $height_orig;
- if ($width / $height > $ratio_orig) {
- $width = $height * $ratio_orig;
- } else {
- $height = $width / $ratio_orig;
- }
- $image_p = imagecreatetruecolor($width, $height);
- $image = imagecreatefromjpeg($src);
- imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
- imagejpeg($image_p, $dest, $quality);
- imagedestroy($image);
- imagedestroy($image_p);
- return true;
- }