0
如何裁剪图像而不是用Php拉伸图像?例如,如果我上传600,100的图像,我希望它在图像的CENTER中裁剪为100x100。因此,从左侧250像素。 显然这些数字将取决于用户上传的图像。Php |没有拉伸的作物图像
这里是我当前的代码:
$width = imagesx($base64);
$height = imagesy($base64);
$tmp = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($tmp, $base64,
0, 0,
0, 0,
$newWidth, $newHeight,
$width, $height);
imagejpeg($tmp, $path)
如果我没有记错的话,这个代码将采取600x100的图像和伸展下来到100×100。反对种植。
这是否解决了您的问题,@Wyatt? – camelsWriteInCamelCase