1
我上传一些图像到我的网页,并希望他们的缩略图是从中心裁剪出的方块。我正在使用Codeigniter和gd2。裁剪缩略图图像在Codeigniter广场
这里是到目前为止我的代码:
$config['image_library'] = 'gd2';
$config['source_image'] = $this->userlibrary->picturesdir . $newfilename;
$config['new_image'] = $this->userlibrary->thumbsdir;
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width']= 150;
$config['height']= 150;
的图像被很好地缩放,但他们保持它们的纵横比和只有它们的宽度或高度被设定为150,它们不会被裁剪。 设置maintain_ratio
仍然不会裁剪图像,而是倾斜它。
我该怎么做?
看看这是你所需要的:http://stackoverflow.com/questions/28002244/crop-resize-image-function-using-gd-library/28008400# 28008400 – Rasclatt
您可以将原始图像裁剪为正方形,然后调整其大小。 – ourmandave