3

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: source image I need to get this: filtered image How i can set one hue color on image with css filter?

doğukan
  • 23,073
  • 13
  • 57
  • 69
Vsevolod Fedorov
  • 481
  • 1
  • 7
  • 20

2 Answers2

4

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">
Temani Afif
  • 245,468
  • 26
  • 309
  • 415
  • oh, its good idea, but how i can calculate properties to get same result as in photoshop? – Vsevolod Fedorov Aug 04 '19 at 14:56
  • 1
    @VsevolodFedorov here it become tricky :) you need to dig into the complex calculation in order to find the formula or you do it with trivial and error until you get the needed result – Temani Afif Aug 04 '19 at 14:58
3

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>
doğukan
  • 23,073
  • 13
  • 57
  • 69