可以将图像混合成颜色吗? (左、右、下)

发布于 2024-08-30 12:12:52 字数 98 浏览 6 评论 0原文

是否可以将图像的左侧、右侧和底部混合成一种颜色?
可以说,我希望将图像混合成颜色“#F0F0F0”。我希望图像显示为背景的实际部分,所以我认为如果将其混合在一起看起来会很酷。

Is it possible to blend the left, right and bottom sides of an image into a color?
Lets say, I want the image to be blended into the color "#F0F0F0". I want the image to appear as an actual part of the background, so I thought it would look cool if it was blended in.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

为人所爱 2024-09-06 12:12:52

如果这仅适用于网页,则可以使用基本的 HTML+CSS。就像你说的,你可以使用 PNG 作为背景上的停留(通过仔细定位的

)。

否则,请查看 PHP 的 ImageMagick 库,因为它们会让您以编程方式创建一个像您所描述的混合图像。 (Imagick::colorizeImage)

If this is just for a webpage this is possible using basic HTML+CSS. Just like you said, you could use a PNG as a layover (via a carefully positioned <div>) on your background.

Otherwise, look into the ImageMagick Libraries for PHP, as they'll let you programmatically create a blended image like you describe. (Imagick::colorizeImage)

雅心素梦 2024-09-06 12:12:52

您可以使用图像操作库来完成此操作,例如 ImageMagickGD。我发现此页面,作者在其中使用使用 GD 执行混合的梯度。

您还可以尝试使用 Imagick::colorizeimage

更新

根据您的屏幕截图,我不明白为什么您不能直接使用 HTML+CSS 来完成您想做的事情。您可以使用透明PNG,也可以使用-moz-opacityopacityfilter:alpha 在你的CSS中(跨浏览器透明度通过CSS)

You can do this by using an image-manipulation library like ImageMagick or GD. I found this page where the author uses a gradient to perform blending using GD.

You can also try using Imagick::colorizeimage

UPDATE

Based on your screenshot, I don't see why you couldn't do what you wanted to with just straight HTML+CSS. You can either use a transparent PNG or you can use -moz-opacity, opacity or filter:alpha in your CSS (Cross-browser Transparency via CSS).

何必那么矫情 2024-09-06 12:12:52

您必须操纵图像的像素数据才能实现此目的,但一旦您涵盖了这一点,它就不再是问题了。获取像素的颜色值并将其与您的混合颜色混合。有一些相当标准的数学可以很好地做到这一点,例如在进行多重纹理时像素着色器中经常使用的算法value1 + (value2 - value1) * amount

正如其他人所说,GD 等 php 图像库有助于图像的数据操作,因为您不必自己对其进行解码和编码

You would have to manipulate the pixeldata of the image to achieve this but once you have that covered its not really a problem. Take the color value of the pixel and blend it with your blendcolor. There are some pretty standard maths that can do it fairly well such as this algorithm value1 + (value2 - value1) * amount often used in pixelshaders when doing multi-texturing.

As others have said image libraries for php such as GD helps out with the data manipulation of the image as you won't have to decode and encode it yourself

两个我 2024-09-06 12:12:52

我不知道你到底需要什么,但是使用半透明 png 作为叠加层,你也可以做很多事情,而无需操作原始图像。

I don't know what you need exactly, but using a semi-transparent png as an overlay you can do a lot as well without the need to manipulate your original images.

同尘 2024-09-06 12:12:52

我建议你使用 verot 的 upload php 类。它包含所有当前可用的处理图像的服务器端操作函数(旋转、色调、框架颜色、背景颜色等)。

请参阅此示例代码:

$foo->image_resize          = true;
$foo->image_ratio_fill      = 'R';
$foo->image_y               = 150;
$foo->image_x               = 100;
$foo->image_background_color = '#FF00FF';
$foo->image_rotate          = '90';

i suggest you use verot's upload php class. It contains all currently available serverside manipulation functions dealing with image (rotate, tint, frame color, background color, etc.).

See this sample code:

$foo->image_resize          = true;
$foo->image_ratio_fill      = 'R';
$foo->image_y               = 150;
$foo->image_x               = 100;
$foo->image_background_color = '#FF00FF';
$foo->image_rotate          = '90';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文