{"id":84,"date":"2014-06-16T13:18:23","date_gmt":"2014-06-16T13:18:23","guid":{"rendered":"http:\/\/www.kiransprojects.com\/blog\/?p=84"},"modified":"2016-11-25T10:55:58","modified_gmt":"2016-11-25T10:55:58","slug":"photoshop-blending-is-broken","status":"publish","type":"post","link":"http:\/\/www.kiransprojects.com\/blog\/2014\/photoshop-blending-is-broken\/","title":{"rendered":"Photoshop Blending Is Broken"},"content":{"rendered":"<p><span style=\"font-size: smaller;\"> *UPDATE* &#8211; <a href=\"http:\/\/blog.dineyin.com\/\">Arthur Gould<\/a> has informed me, as of CS6, Photoshop <em>does<\/em> support multiple layers and other basic tools in 32 bit mode. Converting your image to 32 bit for editing is currently the recommended workflow.<br \/>\n<\/span><\/p>\n<p><center><\/p>\n<h2>An Industry Standard<\/h2>\n<p><\/center><br \/>\nAnyone investigating sRGB color space inconsistencies\u00b9 long enough will eventually reach the ultimate bit of irony. Photoshop (the <em>industry standard<\/em> image manipulation tool) handles all of its blending math completely wrong. This is actually well known among graphics professionals, but the issue <em>is<\/em> slightly technical, so the vast majority of Photoshop users don&#8217;t understand the implications.<br \/>\n&nbsp;<\/p>\n<p><center><\/p>\n<h2>The Tests<\/h2>\n<p><\/center><br \/>\nI have constructed an image that Photoshop fails miserably at downsizing\u00b2. Instead of producing a smaller version of the image, Photoshop just outputs gray.<\/p>\n<p><center><br \/>\n<a href=\"http:\/\/www.kiransprojects.com\/blog\/wp-content\/uploads\/2014\/06\/lena_resize.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-89\" src=\"http:\/\/www.kiransprojects.com\/blog\/wp-content\/uploads\/2014\/06\/lena_resize.jpg\" alt=\"lena_resize\" width=\"512\" height=\"880\" srcset=\"http:\/\/www.kiransprojects.com\/blog\/wp-content\/uploads\/2014\/06\/lena_resize.jpg 512w, http:\/\/www.kiransprojects.com\/blog\/wp-content\/uploads\/2014\/06\/lena_resize-174x300.jpg 174w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/a><br \/>\n<\/center><\/p>\n<p>The image on the left is the correct result, the image on the right is Photoshop\u2019s output. If you don&#8217;t believe me, try it out yourself. Load <a href=\"http:\/\/www.kiransprojects.com\/blog\/wp-content\/uploads\/2014\/06\/lena_grayator.bmp\">this image<\/a> into Photoshop and downsize it by 50%. See? Now, what exactly is going on?<\/p>\n<p>If we take a half black, half white image and resize it down to a 1&#215;1 pixel, we would expect to get a value halfway between the two, the average.<\/p>\n<p><center><br \/>\n<a href=\"http:\/\/www.kiransprojects.com\/blog\/wp-content\/uploads\/2014\/06\/checker_resize.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-86\" src=\"http:\/\/www.kiransprojects.com\/blog\/wp-content\/uploads\/2014\/06\/checker_resize.jpg\" alt=\"checker_resize\" width=\"512\" height=\"880\" srcset=\"http:\/\/www.kiransprojects.com\/blog\/wp-content\/uploads\/2014\/06\/checker_resize.jpg 512w, http:\/\/www.kiransprojects.com\/blog\/wp-content\/uploads\/2014\/06\/checker_resize-174x300.jpg 174w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/a><br \/>\n<\/center><\/p>\n<p>What Photoshop gives us as halfway between (0,0,0) and (255,255,255) is (128,128,128). This answer is wrong. Remember, these numbers are encoded in sRGB space. If we were to properly decode the numbers to linear space, take the average, and re-encode them, we would find the correct result to be (187,187,187). Photoshop gives us an image that is considerably darker than it should be.<\/p>\n<p>Yes, that&#8217;s correct folks, <em>Photoshop can&#8217;t resize images correctly<\/em>.<\/p>\n<p>For the painters in the crowd, what would happen if we took a black brush with 50% opacity and used it on a white background? Will we really get 50% (187)? How about if we used the same brush on a 50% background, will we get 25% (136)?<\/p>\n<p><center><br \/>\n<a href=\"http:\/\/www.kiransprojects.com\/blog\/wp-content\/uploads\/2014\/06\/gray_brush_gamma.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-87\" src=\"http:\/\/www.kiransprojects.com\/blog\/wp-content\/uploads\/2014\/06\/gray_brush_gamma.jpg\" alt=\"gray_brush_gamma\" width=\"512\" height=\"256\" srcset=\"http:\/\/www.kiransprojects.com\/blog\/wp-content\/uploads\/2014\/06\/gray_brush_gamma.jpg 512w, http:\/\/www.kiransprojects.com\/blog\/wp-content\/uploads\/2014\/06\/gray_brush_gamma-300x150.jpg 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/a><br \/>\n<\/center><\/p>\n<p>No, and no, we don&#8217;t get the correct values, which means that the brushes themselves are applied non-linearly. Photoshop brushes react very differently to opacity than what we would expect in a gamma correct editor.<\/p>\n<p>Layer blending modes and filter effects also have the same problem. Everything about Photoshop\u2019s blending is broken. We can blame Adobe for overlooking such a serious issue, but hey, most of us never even noticed!<br \/>\n&nbsp;<\/p>\n<h2>A Partial Solution<\/h2>\n<p>For a limited set of cases, we can devise a way to workaround &#8220;Photoshop Math\u2122&#8221;.<\/p>\n<p>As it turns out, the 32 bit color mode is not in sRGB space because that particular format is intended for use with HDR images and sRGB is only valid in the 0-1 range. HDR images need to extend beyond that. If we want to properly resize an image, we can convert our image&#8217;s mode to 32 bit, do our resize, then convert back to 8 bit (using \u201cExposure and Gamma\u201d with Exposure = 0 and Gamma = 1) . Of course, we can&#8217;t use this trick for much more than resizing because Photoshop is completely gimped in 32 bit mode.<\/p>\n<p><span style=\"font-size: smaller;\"> *UPDATE* &#8211; as stated above, CS6 and beyond has a (mostly) functional 32 bit mode. This is the recommended workflow.<br \/>\n<\/span><\/p>\n<p>Photoshop actually has the ability to do layer blending in linear space. To turn this &#8220;feature&#8221; on we need to hit the checkbox labeled \u201cBlend RGB Colors Using Gamma 1.00\u201d in the Edit-&gt;Color Settings dialog. In my version, I have to hit \u201cMore Options\u201d to see the toggle. Why isn&#8217;t this the default setting for layer blending?<\/p>\n<p>While you\u2019re there, change your Gray Working Space to \u201csGray\u201d, as the default \u201cDot Gain 20%\u201d is designed for print work\u00b3 (and who does <em>that<\/em> anymore?).<\/p>\n<p>If we want to do anything other than resize or blend layers, we&#8217;re out of luck. We can&#8217;t even do both in the same file since 32 bit mode doesn&#8217;t support layers. Jeez!<\/p>\n<p><span style=\"font-size: smaller;\"> *UPDATE* &#8211; Again, as of CS6, there is support for multiple layers in 32 bit mode.<br \/>\n<\/span><br \/>\n&nbsp;<\/p>\n<p><center><\/p>\n<h2>Where Do We Go From Here?<\/h2>\n<p><\/center><br \/>\nIs there an alternative to Photoshop? I&#8217;m not so sure. I&#8217;ve tried a few other image editors out there and they\u2019ve all had similar problems. Will Adobe fix this? I doubt it. The issue has been known for so long, I&#8217;m starting to think they <em>can&#8217;t<\/em> fix it for one reason or another.<\/p>\n<p>If someone is looking to eat Adobe&#8217;s lunch, here&#8217;s your chance. Give us an image editor with correct linear blending. And while you&#8217;re at it, throw in a functional 32 bit mode.<\/p>\n<hr\/>\n<p><span style=\"font-size: smaller;\"><br \/>\n\u00b9 For a better understanding of sRGB and linear color space conversion, I refer you to John Hable&#8217;s <a href=\"http:\/\/filmicgames.com\/archives\/299\">presentation<\/a>.<br \/>\n\u00b2 Inspired by <a href=\"http:\/\/www.4p8.com\/eric.brasseur\/gamma.html\">Eric Brasseur&#8217;s technique<\/a>. I&#8217;ve uploaded my source code to produce the image <a href=\"http:\/\/www.kiransprojects.com\/blog\/wp-content\/uploads\/2014\/06\/photoshop_trick.c\">here<\/a>.<br \/>\n\u00b3 <a href=\"http:\/\/retrofist.com\/sgray\/\">http:\/\/retrofist.com\/sgray\/<\/a><br \/>\n<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>*UPDATE* &#8211; Arthur Gould has informed me, as of CS6, Photoshop does support multiple layers and other basic tools in 32 bit mode. Converting your image to 32 bit for editing is currently the recommended workflow. An Industry Standard Anyone investigating sRGB color space inconsistencies\u00b9 long enough will eventually reach the ultimate bit of irony. &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.kiransprojects.com\/blog\/2014\/photoshop-blending-is-broken\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Photoshop Blending Is Broken&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-84","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.kiransprojects.com\/blog\/wp-json\/wp\/v2\/posts\/84","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.kiransprojects.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.kiransprojects.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.kiransprojects.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.kiransprojects.com\/blog\/wp-json\/wp\/v2\/comments?post=84"}],"version-history":[{"count":10,"href":"http:\/\/www.kiransprojects.com\/blog\/wp-json\/wp\/v2\/posts\/84\/revisions"}],"predecessor-version":[{"id":130,"href":"http:\/\/www.kiransprojects.com\/blog\/wp-json\/wp\/v2\/posts\/84\/revisions\/130"}],"wp:attachment":[{"href":"http:\/\/www.kiransprojects.com\/blog\/wp-json\/wp\/v2\/media?parent=84"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.kiransprojects.com\/blog\/wp-json\/wp\/v2\/categories?post=84"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.kiransprojects.com\/blog\/wp-json\/wp\/v2\/tags?post=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}