php - 我可以使用 PHP 中的 GD 库交换图像中的颜色吗?

标签 php colors gd swap imagefilter

我得到了这样的图像(这是一个图表):

Gold Trade Graph
(来源:kitconet.com)

我想改变颜色,所以白色变成黑色,图形线变成浅蓝色等。可以用 GD 和 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);

enter image description here

关于php - 我可以使用 PHP 中的 GD 库交换图像中的颜色吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/456044/

相关文章:

Android:以编程方式更改单选按钮和复选框的颜色

javascript - 验证 Google 表单中的电子邮件

php - Doctrine原生查询(createNativeQuery) select查询100万行高内存占用

php - 如何获取 xPath nodeValue 美元金额

php - 转义 SphinxSE 中的特殊字符

python - 3D matplotlib : color depending on x axis position

javascript - Winston 3.0 为控制台上的整个输出着色

php - 在php中合并两个图像

php - 使用 GD 或 Imagick 扩展图像 Canvas

php - 如何从 PHP 中的 301 重定向下载链接获取图像?