如何使用CSS滤镜将具有不同颜色的图像色调更改为蓝色色调 [英] How change hue of image with different colors with css filter to hue of blue
问题描述
我有不同颜色的图像.在Adobe Photoshop中,我的图像已使用智能滤镜过滤,从而为图像增加了色相,饱和度和亮度.因此,我需要将图像上的所有颜色更改为蓝色.但是在css中,hue-rotate()函数旋转所有颜色,但是我需要设置一种颜色并更改一些饱和度和亮度.这是源图像:我需要得到这个:如何使用CSS滤镜在图像上设置一种色调颜色?
I have image with different colors. In adobe photoshop my image filtered with smart filter which add hue, saturation, brightness to image. So I need to change all colors on image to hue of blue. But in css hue-rotate() function rotate all colors, but i need to set one color and change some saturation and brightness.This is source image: I need to get this: How i can set one hue color on image with css filter?
推荐答案
您可以考虑 mix-blend-mode
属性.
带有伪元素和背景图片:
With pseudo elements and with background-image:
.img {
background-image: url("https://i.stack.imgur.com/lMWO8.png");
width: 1280px;
height: 302px;
position: relative;
}
.img::before, .img::after {
content: '';
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
}
.img::before {
background-color: gray;
mix-blend-mode: color;
}
.img::after {
mix-blend-mode: overlay;
background-color: green;
}
<div class="img"></div>
或img标签.
.cont {
position: relative;
width: 1280px;
height: 302px;
}
.origin, .color-overlay--1, .color-overlay--2 {
position: absolute;
left:0;
top:0;
width: 100%;
height: 100%;
}
.origin {
z-index:1;
}
.color-overlay--1 {
z-index:2;
background-color:gray;
mix-blend-mode:color;
}
.color-overlay--2 {
z-index:3;
mix-blend-mode:overlay;
background-color:#98aeea;
}
<div class="cont">
<img src="https://i.stack.imgur.com/lMWO8.png" alt="" class="origin">
<div class="color-overlay--1"></div>
<div class="color-overlay--2"></div>
</div>
因此您可以将其转换为所需的任何颜色.
So you can turn it into any color you want.
.cont {
position: relative;
width: 1280px;
height: 302px;
}
.origin, .color-overlay--1, .color-overlay--2 {
position: absolute;
left:0;
top:0;
width: 100%;
height: 100%;
}
.origin {
z-index:1;
}
.color-overlay--1 {
z-index:2;
background-color:gray;
mix-blend-mode:color;
}
.color-overlay--2 {
z-index:3;
mix-blend-mode:overlay;
background-color:red;
}
<div class="cont">
<img src="https://i.stack.imgur.com/lMWO8.png" alt="" class="origin">
<div class="color-overlay--1"></div>
<div class="color-overlay--2"></div>
</div>
这篇关于如何使用CSS滤镜将具有不同颜色的图像色调更改为蓝色色调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!