Хочу его растянуть до 1000х1000 и отрезать лишнее поровну
В итоге справа черная вертикальная полоса в несколько пикселей, почему? что не так?
$side_big = 1000;
list($width_old, $height_old) = getimagesize($photo_old);
if($width_old < $height_old){
$side_old = $width_old;
$x1 = 0;
$y1 = ($height_old - $side_old)/2;
}else{
$side_old = $height_old;
$x1 = ($width_old - $side_old)/2;
$y1 = 0;
}
$fdata = getimagesize($photo_old);
if ($fdata[2] == 1) $src_img = imagecreatefromgif($photo_old);
elseif ($fdata[2] == 2) $src_img = imagecreatefromjpeg($photo_old);
elseif ($fdata[2] == 3) $src_img = imagecreatefrompng($photo_old);
$new_img_big = imagecreatetruecolor($side_big, $side_big);
imagecopyresized($new_img_big, $src_img, 0, 0, $x1, $y1, $side_big, $side_big, $width_old, $height_old);
imagepng($new_img_big, SITE_ROOT."uploads/tmp_crop/".sha1($photo_old.$time).'.png');
if (file_exists($photo_old)) unlink($photo_old);
$return['photo'] = sha1($photo_old.$time);
return $return;
или нужно сначала обрезать под 70х70 а потом растягивать 1000х1000?