我想调整大小和裁剪图像。250x250
我可以调整它的大小:
$newfilename = "image.jpg";
if(isset($_POST['submit'])){
if (isset ($_FILES['new_image'])){
$imagename = $newfilename;
$source = $_FILES['new_image']['tmp_name'];
$target = "img/".$imagename;
move_uploaded_file($source, $target);
$imagepath = $imagename;
$save = "img/" . $imagepath;
$file = "img/" . $imagepath;
list($width, $height) = getimagesize($file) ;
$modwidth = 250;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresized($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
}
}
但我不知道如何在调整大小后裁剪它。它裁剪图像。如果我有 10000x10000 的图像,这是一个错误的决定
imagecopyresized($tn, $image, 0, 0, 0, 0, 250, 250, 250, 250) ;