如何在PHP中实现模糊效果? [英] How to achieve a blur effect in PHP?

查看:87
本文介绍了如何在PHP中实现模糊效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找将高斯模糊应用于图像的PHP代码.

I've been looking for PHP code to apply a Gaussian blur to images.

我所做的就是这样:

<?php
$image = imagecreatefromjpeg('new.jpg'); 
imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR);
imagejpeg($image, 'blur.jpeg');
imagedestroy($image);
?>

但是效果非常弱,如果我重复模糊效果,则需要花费很长时间进行处理,最终结果仍然不是那么好.

However the effect is very weak, and if I repeat the blur effect, it takes a very long time to process and the end result is still not that good.

我也使用Timthumb,我一直喜欢它的简单性,但是默认情况下它会裁剪图像,并且模糊效果非常弱.

I also used Timthumb , I always liked its simplicity, but it crops the image by default and its blurring effect is very weak.

推荐答案

您可以使用ImageMagic

You can use ImageMagic

原始图片

通过exec

convert a.png -blur 0x3 a_blur.png

或运行

convert a.png -blur 0x8 a_blur.png

这篇关于如何在PHP中实现模糊效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆