我正在尝试调整大图像的大小,但图像的外观是使用以下函数进行像素化
function resize($width, $height) {
$this->width = $width;
$this->height = $height;
$this->image_reproportion();
$new_image = imagecreatetruecolor($this->width, $this->height);
imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $this->width, $this->height, $this->getWidth(), $this->getHeight());
$this->image = $new_image;
}
function image_reproportion() {
if (!is_numeric($this->width) OR !is_numeric($this->height) OR $this->width == 0 OR $this->height == 0)
return;
if (!is_numeric($this->getWidth()) OR !is_numeric($this->getheight()) OR $this->getWidth() == 0 OR $this->getheight() == 0)
return;
$new_width = ceil($this->getWidth() * $this->height / $this->getheight());
$new_height = ceil($this->width * $this->getheight() / $this->getWidth());
$ratio = (($this->getheight() / $this->getWidth()) - ($this->height / $this->width));
if ($this->master_dim != 'width' AND $this->master_dim != 'height') {
$this->master_dim = ($ratio < 0) ? 'width' : 'height';
}
if (($this->width != $new_width) AND ($this->height != $new_height)) {
if ($this->master_dim == 'height') {
$this->width = $new_width;
} else {
$this->height = $new_height;
}
}
}
要使用上面的代码我正在调用resize('200','200');
图像路径和文件是正确的。它正在调整大小但图像变得像素化。
答案 0 :(得分:2)
我安装了神奇的Gmagick:)