我可以在PHP中使用GD库交换图像中的颜色吗? [英] Can I swap colors in image using GD library in PHP?
本文介绍了我可以在PHP中使用GD库交换图像中的颜色吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到了这样的图片(这是一个图表):
I got the image like this (it's a graph):
我要更改颜色,因此白色为黑色,图线为浅蓝色等。
I want to change the colours, so the white is black, the graph line is light blue, etc.. is it possible to achieve with GD and PHP?
推荐答案
这将用灰色替换白色
$imgname = "test.gif";
$im = imagecreatefromgif ($imgname);
$index = imagecolorclosest ( $im, 255,255,255 ); // get White COlor
imagecolorset($im,$index,92,92,92); // SET NEW COLOR
$imgname = "result.gif";
imagegif($im, $imgname ); // save image as gif
imagedestroy($im);
这篇关于我可以在PHP中使用GD库交换图像中的颜色吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文