【发布时间】:2019-08-18 06:50:12
【问题描述】:
对于一个学校项目,我需要调整一些图像的大小。老师告诉我们可以使用ImageMagick。但是我没有成功在我的电脑上安装和使用它。
我已经通过 brew 安装了它。而已。对于 windows,所有教程都已过时。
编辑:我忘了说我想在 php 中使用它
【问题讨论】:
-
经过一番搜索,我终于设法使用 GD 调整图像大小。有我的功能: function resize_image($filename, $newwidth) { list($width, $height) = getimagesize($filename); $source = imagecreatefromjpeg($filename); $newheight = $height / ($width / $newwidth); $des = imagecreatetruecolor($newwidth, $newheight); imagecopyresampled($des, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagejpeg($des, $filename, 100); }
标签: php macos xampp imagemagick