Home > php教程 > php手册 > body text

PHP教程:GD库的imagecolorset函数简单修改图片颜色

WBOY
Release: 2016-06-21 08:56:36
Original
2023 people have browsed it

现在有一张背景色为纯蓝色(或者红色等) 并且与照片里人物有很明显的反差色彩 的一寸单人照照片,现想把,该图片中的蓝色背景用PHP处理为白色。即类似于PS中,用白色填充蓝色的效果。

使用GD库的imagecolorset函数可以修改简单的索引色. 不过只能对gif与png图片有效

$img = file_get_contents('http://图片地址);
$im = imagecreatefromstring($img);
$bg = imagecolorat($im, 0, 0);
imagecolorset($im, $bg, 0, 0, 255);
imagepng($im);
imagedestroy($im);
?>



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template