Изменение размера изображения php-формы

У меня есть два типа загрузки изображения: первое высокое разрешение:

$specialImages = count($_FILES['specialImg']['name']); $specialMinwidth = 3000; $specialMinheight = 2500; $urlSpecialImages = array(); if ($specialImages) { for ($i=1; $i<=$specialImages; $i++) { if ($_FILES['specialImg']['name'][$i] != "") { if ((($_FILES['specialImg']['type'][$i] == "image/pjpeg") || ($_FILES['specialImg']['type'][$i] == "image/jpeg") || ($_FILES['specialImg']['type'][$i] == "image/png")) && ($_FILES['specialImg']['size'][$i] < $this->return_bytes(ini_get('post_max_size')))) { list($width, $height, $type, $attr) = getimagesize($_FILES['specialImg']['tmp_name'][$i]); if ($width >= $specialMinwidth && $height >= $specialMinheight) { $urlSpecialImages[$i] = $_FILES['specialImg']['tmp_name'][$i]; } else { $this->errors[] = $this->module->l("L'image doit être au format minimum de 3000px x 2500px", 'addproduct'); } 

второе низкое разрешение:

  $images = count($_FILES['images']['name']); $minwidth = 1500; $minheight = 1500; if ($images <= Configuration::get('JMARKETPLACE_MAX_IMAGES')) { for ($i=1; $i<=Configuration::get('JMARKETPLACE_MAX_IMAGES'); $i++) { if ($_FILES['images']['name'][$i] != "") { if ((($_FILES['images']['type'][$i] == "image/pjpeg") || ($_FILES['images']['type'][$i] == "image/jpeg") || ($_FILES['images']['type'][$i] == "image/png")) && ($_FILES['images']['size'][$i] < $this->return_bytes(ini_get('post_max_size')))) { list($width, $height, $type, $attr) = getimagesize($_FILES['images']['tmp_name'][$i]); if ($width == $minwidth && $height == $minheight) { $url_images[$i] = $_FILES['images']['tmp_name'][$i]; } else { $this->errors[] = $this->module->l('The image format need to be 1500 x 1500 pixels', 'addproduct'); } 

Я хочу использовать специальные $ specialImages, загруженные и измененные. 1500×1500 на изображениях с низким разрешением! потому что я хочу получить оба разрешения одной загрузкой! Как я могу это сделать ?

Пример функции изменения размера изображения:

 function resizeImage($file = 'image.png', $maxwidth = 1366){ error_reporting(0); $image_info = getimagesize($file); $image_width = $image_info[0]; $image_height = $image_info[1]; $ratio = $image_width / $maxwidth; $info = getimagesize($file); if ($image_width > $maxwidth) { // GoGoGo $newwidth = $maxwidth; $newheight = (int)($image_height / $ratio); if ($info['mime'] == 'image/jpeg') { $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($file); imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $image_width, $image_height); echo imagejpeg($thumb,$file,90); } if ($info['mime'] == 'image/jpg') { $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($file); imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $image_width, $image_height); echo imagejpeg($thumb,$file,90); } if ($info['mime'] == 'image/png') { $im = imagecreatefrompng($file); $im_dest = imagecreatetruecolor($newwidth, $newheight); imagealphablending($im_dest, false); imagecopyresampled($im_dest, $im, 0, 0, 0, 0, $newwidth, $newheight, $image_width, $image_height); imagesavealpha($im_dest, true); imagepng($im_dest, $file, 9); } if ($info['mime'] == 'image/gif') { $im = imagecreatefromgif($file); $im_dest = imagecreatetruecolor($newwidth, $newheight); imagealphablending($im_dest, false); imagecopyresampled($im_dest, $im, 0, 0, 0, 0, $newwidth, $newheight, $image_width, $image_height); imagesavealpha($im_dest, true); imagegif($im_dest, $file); } }} 

Использование:

 resizeImage('D:\tmp\11.png', 1366);