Я пытался изменить размер изображения с помощью , используя следующий метод:
код
$thumbimg = $img->resizeImage($thumb, 200, 200);
public function resizeImage($imagePath,$new_width,$new_height) {
$fileName = pathinfo($imagePath,PATHINFO_FILENAME);
$ext = pathinfo($imagePath,PATHINFO_EXTENSION);
$fullPath = pathinfo($imagePath,PATHINFO_DIRNAME)."/".$fileName.'.'.$ext;
if (file_exists($fullPath)) {
return $fullPath;
}
$image = $this->openImage($imagePath);
if ($image == false) {
return null;
}
$width = imagesx($image);
$height = imagesy($image);
$imageResized = imagecreatetruecolor($width, $height);
if ($imageResized == false) {
return null;
}
$image = imagecreatetruecolor($width , $height);
$imageResized = imagescale($image,$new_width,$new_height);
touch($fullPath);
$write = imagepng($imageResized,$fullPath);
if (!$write) {
imagedestroy($imageResized);
return null;
}
imagedestroy($imageResized);
return $fullPath;
}
Фактически это сохраняетмои изображения в оригинальной ширине и высоте.Но почему?Что не так?