【发布时间】:2011-07-15 15:29:46
【问题描述】:
我正在使用这个功能
function resize($width,$height) {
$new_image = imagecreatetruecolor($width, $height);
imagesavealpha($new_image, true);
$trans_colour = imagecolorallocatealpha($new_image, 0, 0, 0, 127);
imagefill($new_image, 0, 0, $trans_colour);
imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
$this->image = $new_image;
}
我想做的是制作一个方形图像。我想通过最小的属性来调整大小,而不是更大的数字被压扁。我想把边缘切掉。
所以,如果我有一个 213 x 180 的图像,我需要将其大小调整为 150 x 150
我可以在图像触发此功能之前将图像大小调整为 150 高度。
我不知道该怎么做是取宽度并切掉边缘以获得 150 宽度而不会变形。
有人知道怎么做吗?
【问题讨论】:
-
所以你想在调整大小之前裁剪图像正方形?为什么不调整大小保持纵横比,然后裁剪掉大于 150 的尺寸?
-
如果你不想搞低级图像操作,强烈推荐使用宽图像库(wideimage.sourceforge.net)。
标签: php image-processing image-manipulation