Zyl Posted September 23, 2020 Share Posted September 23, 2020 (edited) I made a simple 16x16 pixel file with a black vector triangle. I export this to PNG using the default settings, and inspect the result in MS Paint. The channel values of the center diagonal of grey pixels are 127, revealing that either the document has been saved in linear RGB or colors have been blended in sRGB color space. This matches what is visible while viewing and editing the project within Affinity Designer with "Pixel View mode" enabled: I want color information to be saved in sRGB. More precisely, I want all color blending operations to happen in linear RGB, and color display and export to happen in sRGB. Embedding the correct color profile into the file is not sufficient, as converting every channel to byte is already a highly lossy operation. How can I achieve this? Edited September 23, 2020 by Zyl Quote Link to comment Share on other sites More sharing options...
Zyl Posted September 23, 2020 Author Share Posted September 23, 2020 For comparison, the following is the result of the same in Photoshop with blending using gamma enabled: Each channel assumes a value of 188, which is the nearest sRGB representation for a pixel with 50% white and 50% black coverage in byte-encoding. Quote Link to comment Share on other sites More sharing options...
v_kyr Posted September 23, 2020 Share Posted September 23, 2020 A quite good explanation for linear RGB vs sRGB can be found in the answers here. - AFAI recall tools like Maya do allow a linear workflow here. Basically linear RGB vs sRGB is nearly Gamma 1.0 vs Gamma 2.2, see also the following about brightness subpixel transformation here. Quote ☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan ☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2 Link to comment Share on other sites More sharing options...
lacerto Posted September 24, 2020 Share Posted September 24, 2020 (...) Quote Link to comment Share on other sites More sharing options...
Zyl Posted September 24, 2020 Author Share Posted September 24, 2020 Here is a comparison which makes the advantage of blending in linear RGB quite apparent. Affinity: Photoshop: In case you have a high DPI display, I follow up with the same but at 2x resolution, with nearest neighbor interpolation. Affinity: Photoshop: The keen eye will be able to tell that the edges of the shape are more jagged in Affinity Designer's output. The cause of this outcome is purely mathematical. Blending in sRGB violates conservation of energy. Quote Link to comment Share on other sites More sharing options...
Zyl Posted September 26, 2020 Author Share Posted September 26, 2020 So... can we or can we not currently do this? Quote Link to comment Share on other sites More sharing options...
Staff James Ritson Posted September 26, 2020 Staff Share Posted September 26, 2020 On 9/23/2020 at 7:20 PM, Zyl said: I want color information to be saved in sRGB. More precisely, I want all color blending operations to happen in linear RGB, and color display and export to happen in sRGB. Embedding the correct color profile into the file is not sufficient, as converting every channel to byte is already a highly lossy operation. How can I achieve this? Apologies if I’ve misunderstood this, but couldn’t you just use 32-bit format for your document? 32-bit in all the apps uses linear compositing but has a gamma-corrected view transform applied non-destructively so the document view looks consistent with the exported result (as you would typically export to a non-linear format with gamma encoded values). You can toggle this behaviour on the 32-bit preview panel if you need the linear unmanaged view (or an OpenColorIO transform) but it defaults to ICC Display Transform which is the exact workflow you describe: all colour blending operations happen in linear space, with a final view transform to non-linear space. If you wanted linear compositing within a non-linear RGB document format (so 8-bit or 16-bit), you could approximate this by using two live Procedural Texture layers: one underneath the layers you wish to blend in linear space, and one above. The one beneath you would create equation fields for each channel and transform the channel value by 2.2 (e.g. R^2.2), then the one above you would transform by the reciprocal power value, so R^0.454 etc. Just an approximation, but perhaps close enough for your needs? I’ve attached some screen grabs: I exported two 16x16 images with a black triangle—one composited in 32-bit, one in 16-bit. To visualise them, I loaded them back into Photo and screen grabbed the resulting document views: Finally, here is a 16-bit non-linear sRGB document using the live Procedural Texture technique I mentioned above: Hope that helps! Quote Product Expert (Affinity Photo) & Product Expert Team Leader @JamesR_Affinity for tutorial sneak peeks and more Official Affinity Photo tutorials Link to comment Share on other sites More sharing options...
Zyl Posted September 27, 2020 Author Share Posted September 27, 2020 Thanks for the detailed response. Unfortunately, I cannot reproduce the behavior you describe. Here is what I do: It's still blended in sRGB, even after export, despite having chosen 32 bit color format as you advised. What is wrong? Quote Link to comment Share on other sites More sharing options...
lepr Posted September 27, 2020 Share Posted September 27, 2020 1 hour ago, Zyl said: Thanks for the detailed response. Unfortunately, I cannot reproduce the behavior you describe. Here is what I do: It's still blended in sRGB, even after export, despite having chosen 32 bit color format as you advised. What is wrong? I suspect you did not have a white object as the background in the linear 32 bpc Affinity document. In the Affinity view of the linear document, the matting of the anti-aliased black object against the canvas white would have been done in the linear colour space. However, when exporting to a gamma encoded 8 or 16 bpc file, the anti-aliased black object will have been matted against white in the gamma encoded colour space of the export. To get the export result that you want, you need to use an actual white object as the background, not empty canvas. By the way, the blend options for an object (click the cog wheel at top-right of Layers panel) allow you to specify linear blending for that object when working in the gamma-encoded colour space of an 8 or 16 bpc document. It doesn't work correctly for everything, but it will for your example. Remember to use an actual white background, not empty canvas, though. Zyl 1 Quote Link to comment Share on other sites More sharing options...
Zyl Posted September 27, 2020 Author Share Posted September 27, 2020 2 hours ago, anon2 said: I suspect you did not have a white object as the background Yep, that was it. I have to admit though I don't really understand why the background is subject to special treatment like so. Quote By the way, the blend options for an object (click the cog wheel at top-right of Layers panel) allow you to specify linear blending for that object when working in the gamma-encoded colour space of an 8 or 16 bpc document. This is good to know! I'm not really sure what are some use cases to want to blend in sRGB specifically. I imagine an overwhelming amount of hobbyists, and even some professionals, aren't even aware that getting this wrong can negatively affect their results. Even if they notice pixelated lines or such, they might just shrug it off as consequence of too low DPI, not knowing that something can be done about it. As a hobbyist, I can only attest to having learned about it by chance, and that thus I strongly feel that defaulting to anything other than blending in linear RGB is undesirable. Anyways, I got everything indistinguishably close to what Photoshop produces (the exact values are off by up to 2 in the 8 bit export, but that doesn't matter) and it's looking good, so I call this a closed case. Thanks, all! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.