How change hue of image with different colors with css filter to hue of blue

我的未来我决定 提交于 2021-02-08 03:59:24

问题


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?


回答1:


You can consider mix-blend-mode property.

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>

Or img tags.

.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>



回答2:


You can combine a sepia filter with hue-rotate to approximate it:

img {
 max-width:100%;
 filter:sepia(1) hue-rotate(149deg);
}
<img src="https://i.stack.imgur.com/lMWO8.png">


来源:https://stackoverflow.com/questions/57347508/how-change-hue-of-image-with-different-colors-with-css-filter-to-hue-of-blue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!