我想調整大小和裁剪圖像。 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) ;
這並不是他所要求的,說實話,這是一個非常懶惰和浪費的方式來做到這一點。 –
比例是多少? – Dobrozhelatel