在PHP中调整图像脚本的大小


Resizing image script in PHP

我需要一个用PHP调整图像大小的脚本,实际上我需要这样的东西:https://gist.github.com/nomisoft/11403298这个脚本已经很完美了,但调整大小的gif图像没有动画。我需要以最高质量调整gif、jpg、jpeg和png图像的大小,然后再对gif图像进行动画处理;png图像是透明的。

抱歉英语不好。非常感谢。

对于动画GIF图像,您可以使用https://github.com/glukash/glu-image

适用于JPG、JPEG、PNG等。http://image.intervention.io/api/makehttp://image.intervention.io/api/resize

$this->image_manager = new Intervention'Image'ImageManager(['driver' => 'imagick']);
$this->max_width = 800;
public function resizeImage($resource) {
$image = $this->image_manager->make($resource);
if ($image->width() <= $this->max_width) {
    return $resource;
}
return $image->resize($this->max_width, null, function ($constraint) {
        $constraint->aspectRatio();
        $constraint->upsize();
     })->save();
}