失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > PHP图片处理库Grafika详细教程

PHP图片处理库Grafika详细教程

时间:2019-04-11 01:33:52

相关推荐

PHP图片处理库Grafika详细教程

php教程|PHP开发

php 图片处理 图片压缩 图片切片

php教程-PHP开发

图片过滤、滤镜

行情直播源码免费下载,vscode关闭受限模式,ubuntu rpm查找,tomcat版本怎么更换,爬虫金刚,php 双斜杠,李沧区360seo优化,网站电脑模板,贴吧网站模板lzw

grafika提供了11种滤镜功能,可以满足开发中的任何情况需求。

芒果云3.0源码,使用vscode开发go,ubuntu适合人群,删除tomcat安装教程,扁形爬虫,centos php发布,seo优化不显示图片,discuz门户网站源码,把五删掉发给我的模板lzw

这里先介绍一个操作方法:apply:它可以将滤镜效果应用到图片

源码下载站哪家好用,ubuntu无法启动了,爬虫统治地球前,php xaxis,武汉seo标题lzw

图片模糊

使用Blur参数,模糊化一张图片

其中模糊度取值范围为0-100,数值越大,图片越模糊

use Grafika\Grafika;$editor = Grafika::createEditor();$editor->open( $image, yanying-smaller.jpg );$filter = Grafika::createFilter(Blur, 50); // 模糊度为10,模糊度取值为0-100$editor->apply( $image, $filter ); // 将滤镜应用到图片$editor->save($image,yanying-blur.jpg);

我们将图片模糊参数调为50

图片亮度调整

使用Brightness,加亮或者变暗图片

其中亮度值取值范围为

-100 至 -1,变暗

0 图片没有变化

1-100图片变量

use Grafika\Grafika;$editor = Grafika::createEditor();$editor->open( $image, yanying-smaller.jpg );$filter = Grafika::createFilter(Brightness, -50);$editor->apply( $image, $filter );$editor->save($image,333/yanying-Brightness-1.jpg);

改变图片颜色

使用Colorize参数,调整图片的红绿蓝三个基础色来改变图片颜色

颜色参数(红色、绿色、蓝色取值范围相同)

取值-100至-1,颜色减少;

如果为0表示不变;

取值1-100,表示色值增加

use Grafika\Grafika;$editor = Grafika::createEditor();$editor->open( $image, yanying-smaller.jpg );$filter = Grafika::createFilter(Colorize, -50,50,-50);$editor->apply( $image, $filter );$editor->save($image,333/yanying-Colorize.jpg);

改变图片对比度

使用Contrast参数可以改变图片的对比度

对比度的取值和之前的也差不多,-100至-1,对比度减少;0不变;1至100,对比度增加

具体什么叫对比度,自行百度,我也不是太清楚,毕竟不是搞设计的

use Grafika\Grafika;$editor = Grafika::createEditor();$editor->open( $image, yanying-smaller.jpg );$filter = Grafika::createFilter(Contrast, 50);$editor->apply( $image, $filter );$editor->save($image,333/yanying-Contrast.jpg);

图像色阶调整

Gamma这个参数在平时是不常用的,只有在专业的图像领域才会使用。可以理解为色阶,是灰阶亮度值与灰阶等级之间的数学关系。

这里的Gamma功能是校正图像色阶,使得图像看起来颜色更加正确

这里的数字值取值范围只有最小值没有最大值只要 >=1.0都可以

use Grafika\Grafika;$editor = Grafika::createEditor();$editor->open( $image, yanying-smaller.jpg );$filter = Grafika::createFilter(Gamma, 2.0);$editor->apply( $image, $filter );$editor->save($image,333/yanying-Gamma.jpg);

图片灰度

使用Grayscale使图片所有的色彩丢弃,只保留黑白两种颜色,没有取值。

use Grafika\Grafika;$editor = Grafika::createEditor();$editor->open( $image, yanying-smaller.jpg );$filter = Grafika::createFilter(Grayscale);$editor->apply( $image, $filter );$editor->save($image,333/yanying-Grayscale.jpg);

图像反色处理

图像反色,也就是弄得和胶片似得。

使用Invert参数可以达到图像反色效果,也没有可选值

use Grafika\Grafika;$editor = Grafika::createEditor();$editor->open( $image, yanying-smaller.jpg );$filter = Grafika::createFilter(Invert);$editor->apply( $image, $filter );$editor->save($image,333/yanying-Invert.jpg);

图片像素化、栅格化

就是把矢量图形转换成像素点组成的点阵图形,也叫栅格化。搞ps的应该都清楚

该参数有个取值范围只要大于或者等于1就可以,如果值越大,像素点也就越大

use Grafika\Grafika;$editor = Grafika::createEditor();$editor->open( $image, yanying-smaller.jpg );$filter = Grafika::createFilter(Pixelate,10);$editor->apply( $image, $filter );$editor->save($image,333/yanying-Pixelate-10.jpg);

我们取值5和取值10对比下图片锐化

图片锐化就是补偿图像的轮廓,增强图像的边缘及灰度跳变的部分,使图像变得清晰。

使用参数Sharpen可以处理锐化,其取值为1-100(包含)。

use Grafika\Grafika;$editor = Grafika::createEditor();$editor->open( $image, yanying-smaller.jpg );$filter = Grafika::createFilter(Sharpen,50);$editor->apply( $image, $filter );$editor->save($image,333/yanying-Sharpen.jpg);

我们取值50,看下效果图像查找边缘

通过数学计算检测出图像的边缘,在ps中较为常用。

这里使用Sobel参数达到相同效果,没有值可选

use Grafika\Grafika;$editor = Grafika::createEditor();$editor->open( $image, yanying-smaller.jpg );$filter = Grafika::createFilter(Sobel);$editor->apply( $image, $filter );$editor->save($image,333/yanying-Sobel.jpg);

如果觉得《PHP图片处理库Grafika详细教程》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。