PHP 怎么去掉一张图片里的一些颜色,让其变成透明?
把一张图片(根据指定的RGB颜色范围)透明化。但是实际处理当中,下面的代码值移除了白色,请教是怎么回事?$o_pic = '1.jpg';
//要处理的色阶起始值
$begin_r = 215;
$begin_g = 215;
$begin_b = 215;
list($src_w,$src_h,$src_type) = getimagesize($o_pic);// 获取原图像信息
$file_ext = get_ext($o_pic);//获取扩展名
$target_im = imagecreatetruecolor($src_w,$src_h);//新图
if($file_ext == 'jpg') //转换JPG 开始
{
$src_im = ImageCreateFromJPEG($o_pic);
imagecopymerge($target_im,$src_im,0,0,0,0,$src_w,$src_h,100);
for($x = 0; $x < $src_w; $x++)
{
for($y = 0; $y < $src_h; $y++)
{
$rgb = imagecolorat($src_im, $x, $y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
if($r > $begin_r && $g > $begin_g && $b > $begin_b ){
imagecolortransparent($target_im, imagecolorallocate($target_im,$r, $g, $b));
}
}
}
}
相关阅读:
Laravel点击页面链接按某一条件排序,这个页面的更新链接应该如何写?
网站上的视频功能是如何实现的?
javascript数组长度问题
php中exec("ffmpeg -y -i {$amr} {$mp3}");
ci框架里的ar模型如何使用mysql函数?
hexo 3.0 为什么无法部署到github上
SpringMVC不设置request.setAttribute也可以在jsp中的el表达式里取到值?
UITableViewCell 重用问题,关于Button highlighted 显示不正确
通过js动态增加html节点
python用xlwt写excel错误
google map 今年5月份升级后的坐标系是什么坐标系?
如何实现京东只加载第一屏的方法
Linux流媒体服务器?
sed匹配JSON数据中的数字
insertBefore到底有什么问题,没反应??
请问 直接学习 Spring mvc 框架没问题吧
移动端type=date部分浏览器多出灰色外框
js构造函数实例对象传入构造函数,arguments[0].prototype为啥是Object?
平衡二叉树DSW算法的实现?
用highcharts制作饼图时labels位置问题