I have working CSS filters on the <img />
elements as I want to.
eg.
filter: brightness(1) contrast(67%) saturate(250%) grayscale(0%) invert(0%) hue-rotate(330deg) sepia(40%) blur(0px);
My gol is to apply the same filter properties to the <image />
tag inside SVG file.
However things like
<g style="-webkit-filter: contrast(67%) saturate(250%);">
<image xlink:href="image.jpg" />
</g>
or
<image xlink:href="image.jpg" style="-webkit-filter: contrast(67%) saturate(250%) sepia(40%)"/>
does not work.
So most likely I have to combine CSS filters as SVG filters.
On webplatform.org I found SVS's represnetation of particular CSS filter effects, eg:
then I have tried to combine generated filters with feMerge
.
<filter id="clip_1-filter-90117969876336">
<feComponentTransfer in="SourceGraphic" result="brightness-filter">
<feFuncR type="linear" slope="22"></feFuncR>
<feFuncG type="linear" slope="22"></feFuncG>
<feFuncB type="linear" slope="22"></feFuncB>
</feComponentTransfer>
<feComponentTransfer in="brightness-filter" result="contrast-filter">
<feFuncR type="linear" slope="-15" intercept="7"></feFuncR>
<feFuncG type="linear" slope="-15" intercept="7"></feFuncG>
<feFuncB type="linear" slope="-15" intercept="7"></feFuncB>
</feComponentTransfer>
<feColorMatrix in="contrast-filter" result="grayscale-filter" type="matrix" values="
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0"></feColorMatrix>
<feComponentTransfer in="SourceGraphic" result="invert-filter">
<feFuncR type="table" tableValues="0 1"></feFuncR>
<feFuncG type="table" tableValues="0 1"></feFuncG>
<feFuncB type="table" tableValues="0 1"></feFuncB>
</feComponentTransfer>
<feMerge>
<feMergeNode in="grayscale-filter"></feMergeNode>
</feMerge>
</filter>
However the results are far from expected.
What is the proper way of translating CSS filters to the SVG?