【发布时间】:2016-11-08 06:37:23
【问题描述】:
我需要在具有透明度的 PNG 图像中将黄色的每个色调更改为蓝色,并将深灰色的每个色调更改为浅灰色。
问题是:
我不能使用 Photoshop,因为我有 100 张图像,而且我需要多次更改色调。 我不能使用 Image Magick,因为我需要比“-fx”更复杂的计算。 我不能使用 PHP imagefrompng(),因为这个讨厌的废话不适用于我的很多图像, 即使有所有建议的修复,例如:
$background = imagecolorallocate($png, 255, 255, 255);
// removing the black from the placeholder
imagecolortransparent($png, $background);
// turning off alpha blending (to ensure alpha channel information is preserved, rather than removed (blending with the rest of the image in the form of black))
imagealphablending($png, true);
// turning on alpha channel information saving (to ensure the full range of transparency is preserved)
imagesavealpha($png, true);
等等。它适用于某些图像,但不适用于其他图像。
我只需要一个 PNG 库(可能不在 PHP 中),它可以为我提供坐标 x、y 处像素的红色、绿色、蓝色和 alpha 分量,然后在计算后设置此像素,例如:
$rgba = getrgba($image, $x, $y);
$rgba = my_function($rgba);
setrgba($image, $x, $y, $rgba);
也许您可以推荐其他语言的库,而不仅仅是 PHP?
【问题讨论】:
-
欢迎来到 Stack Overflow!请花些时间阅读介绍性的tour。要求我们推荐或查找书籍、工具、软件库、教程或其他场外资源的问题对于 Stack Overflow 来说是无关紧要的,因为它们往往会吸引固执己见的答案和垃圾邮件。另见Help center:What topics can I ask about here?
标签: php png rgb photoshop rgba