Related to my other question, I need to convert my SVG to a 16-bit TIFF, which seems to be more complicated than expected. So I wanted to check Photoshop and Gimp, but they both (along with Figma) don't render my SVG correctly, so I wonder if anything is wrong with my code (here a simple example file, the original is basically the same just with a lot more rectangles):
<svg xmlns="http://www.w3.org/2000/svg" width="1000" height="1000" viewBox="0 0 1000 1000">
<defs>
<linearGradient id="g">
<stop offset="0%" stop-color="#0f0"></stop>
<stop offset="50%" stop-color="#000"></stop>
<stop offset="100%" stop-color="#0f0"></stop>
</linearGradient>
<linearGradient id="b" gradientTransform="rotate(90)">
<stop offset="0%" stop-color="#00f"></stop>
<stop offset="50%" stop-color="#000"></stop>
<stop offset="100%" stop-color="#00f"></stop>
</linearGradient>
</defs>
<rect x="0" y="0" width="1000" height="1000" fill="#fff"></rect>
<g>
<rect x="100" y="100" width="300" height="300" fill="url(#g)"></rect>
<rect x="600" y="600" width="300" height="300" fill="url(#g)"></rect>
</g>
<g style="mix-blend-mode:screen">
<rect x="100" y="100" width="300" height="300" fill="url(#b)"></rect>
<rect x="600" y="600" width="300" height="300" fill="url(#b)"></rect>
</g>
</svg>
This is what it should look like (converted to PNG by CloudConvert): In Photoshop and Gimp, only the blue layer renders, so it seems like the blend mode is ignored? In Figma (not that important for my case, but still) there seems to be a different problem with the gradient coordinates. But the browser displays it correctly, also CloudConvert seems to be fine with it.
So is this a problem with my code and the browser is just very forgiving, or are the SVG modules of Photoshop and Gimp broken?
Maybe the style
needs to be applied to the individual <rects>
s? But MDN says
Transformations applied to the
<g>
element are performed on its child elements, and its attributes are inherited by its children.
so it should be fine?
mix-blend-mode:screen
CSS property is definitely the culprit here. Please note that it's not part of any SVG specification. The reason some browsers support it is because they already support it for regular HTML elements and just enabled it for SVG elements as well, even though they are not required to by the spec.<feBlend>
). It's a little more involved and is not guaranteed to be supported everywhere either, though. Especially if you want to blend objects with other objects in the background (usingBackgroundImage
as the source). I can write a full answer explaining how, if you want.