Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
There are libraries that resize and crop images, for example, I have this:
function imageResize($file_path, $new_width){
//Получаем ширину и высоту исходника
list($w, $h) = getimagesize($file_path);
//Получаем коэфицент соотношения сторон
$proportions = $h / $w;
$new_w = $new_width;
$new_h = $new_w * $proportions; // Получаем высоту уменьшенной картинки пропорционально новой ширине
$thumb = imagecreatetruecolor($new_w, $new_h);
$source = imagecreatefromjpeg($file_path);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $new_w, $new_h, $w, $h);
imagejpeg($thumb, $_FILES['image']['tmp_name']);
return $_FILES['image']['tmp_name'];
imagedestroy($thumb);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question