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?

2 Answers 2

5

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.sstatic.net/lMWO8.png">

2
  • oh, its good idea, but how i can calculate properties to get same result as in photoshop? Commented Aug 4, 2019 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 Commented Aug 4, 2019 at 14:58
3

You can consider mix-blend-mode property.

With pseudo elements and with background-image:

.img {
  background-image: url("https://i.sstatic.net/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.sstatic.net/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.sstatic.net/lMWO8.png" alt="" class="origin">
  <div class="color-overlay--1"></div>
  <div class="color-overlay--2"></div>
</div>

2
  • oh, i have one more question. How i can do that with transparent image? I don't want to see blue background on transparent area Commented Aug 4, 2019 at 16:04
  • @VsevolodFedorov you can give them all opacity?
    – doğukan
    Commented Aug 4, 2019 at 16:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.