📜 ⬆️ ⬇️

Optimization of gradients in Photoshop

The material is, rather, for beginner maker-ups, for example, such that they work at Microsoft;) On the subject came across one picture from one popular page :

image

The fact is that the picture weighs 55 211 bytes. But it is the same , but the size is 1 764 bytes. If you think that the difference is in the format (I have png, and in the original gif), then you are only partially correct. Try to resave the original image in png, it is unlikely that you will get a serious win (my size was 45 kb). In general, this is not the format.
')

It's all about the rasterization method of the gradient.


First, let's think about how to draw a gradient.

For simplicity, we assume that we have one color component, gray. We need a gradient from color 10 to color 20 (from very black to slightly lighter) with a height of 40 pixels. What to do to the program which draws a gradient, if intermediate values ​​of color 10, and gradient height 40 pixels? It has 2 outputs: either make strips of 4 pixels of the same color, or use some clever masks so that the adjacent pixels are of different colors, but their overall intensity varies evenly. It is clear that the second method may be more pleasant for the eyes, while the former can be much better compressed. In order to somehow illustrate the differences, I set the contrast almost at the maximum for my and Microsoft pictures:

image

What about photoshop?


But which of these algorithms does Photoshop use? It depends on whether you have this tick on the “gradient” toolbar:
image

In addition, if the gradient is drawn by the “Gradient overlay” effect on a layer, then the gradient will always be without dither.

I think it is clear that in this case the gradient without dither will be a good choice. It was he who applied in my picture.

But there are also cases when the gradient without dither does not look very good:
image

Perhaps not on every monitor will be noticeable, but this gradient consists of individual diagonal stripes of color.

At the same time, the dither version looks much better:
image

True and it weighs, like the picture with which it all started, 50+ kilobytes. For such cases, I would recommend saving the image in jpg format with a quality of 100. From this, the quality will not deteriorate a lot, but the size will be acceptable to the wave - 8 kb .

Source: https://habr.com/ru/post/80352/


All Articles