PHP Imagick API:如何将图像的色调更改为已知的十六进制值
我创建模板网站。如果客户选择蓝色、绿色或紫色标题,我不想存储图像的所有这些不同颜色变化。我想以编程方式更改色调。我不想“淹没”它,因为这会删除任何纹理或斜角。
例如,您看到的页面我已经完成了我想要的。 http://sta.oursitesbetter.com/test/index.php
我已经完成这使用 Imagick modulateImage 函数。
然而,我只是抛出随机的“色调”值而不是 RGB 值。我想完成同样的事情,输入 RGB 值。我需要一个类似于 modulateImage 的函数,但它必须采用 RGB 作为值并将图像设置为该色调。
我已经研究了过去5个小时,但不知道该怎么做。我需要帮助。
StackOverflow 的专家是否有 PHP Imagick 解决方案来解决这个颜色难题?
I create template websites. If a client choose a blue or green or purple heading, I don't want to have to store all those different color variations of an image. I want to programmatically change the hue. I do not want to 'flood fill' it because that would remove any textures or bevels.
For example page you see I have accomplished exactly what I want.
http://sta.oursitesbetter.com/test/index.php
I have done this using Imagick modulateImage function.
HOWEVER, I am just throwing random 'Hue' values and not RGB values. I want to accomplish this same thing feeding RGB values. I need a function similar to modulateImage however it must take RGB as value and set the image to that hue.
I have studied for the past 5 hours and cannot figure out how to do it. I need help.
Has any of the gurus of StackOverflow got a PHP Imagick solution to this color quandary?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自 维基百科:Hue #Computing Hue from RGB:
From Wikipedia: Hue #Computing hue from RGB:
另一种选择可能是使用 ImageMagick 以您想要的 RGB 颜色创建单个像素图像,然后查看 ImageMagick 在 HSL 色彩空间中的效果。假设您的 RGB 值为 25,126,200,您可以这样做:
以下等效方法可能更简洁:
因此,IM 使其色调为 57.0474%。当然,您不需要运行它并解析文本输出,我这样做只是为了演示这个概念 - 您可以直接在 PHP 中访问像素。
Another option might be to use ImageMagick to create a single pixel image in the RGB colour you want and then see what ImageMagick makes that in HSL colorspace. Say your RGB values are 25,126,200, you could do this:
The following equivalent methods are maybe a little more succinct:
So, IM makes that a Hue of 57.0474%. Of course you don't need to run that and parse the text output, I am only doing that to demonstrate the concept - you can access the pixel directly in PHP.