This is a bit of a refactor of thumbnail creation. There is no overlap between this and D9404 and D9397.
We create and save preview images of some types of files as small thumbnail images saved on the file system for later retrieval. We do so while following the "[[ https://specifications.freedesktop.org/thumbnail-spec/latest/t1.html | Thumbnail Managing Standard ]]". This patch just cleans up the code related to this and extends it a bit further. The main function, thumb_create_ex(), is cleaned up, variables renamed, more early returns, etc to greatly simplify it.
One reason behind this standard is to "provide further information about a file in its thumbnail. Especially file size, image dimension or image type are often used in graphic programs. If the thumbnail provides such information it avoids any need to access the original file". Basically we want to know as much as possible about the target file without having to load it. So this patch extends that a bit more...
The following shows the PNG metadata currently added by blender to an image file at the top. The "Thumb Image" dimensions are (obviously) the dimensions of the target file, not that of the thumbnail itself. The bottom shows what is added after this patch, so including more details about the image:
{F9197254}
Similarly, the thumbnail of a video will contain the dimensions of the video, how many frames, duration, etc
{F9197270}
Thumbnails for fonts also includes family name (often different from the file name), whether it is bold, italic, or monospaced, and how my glyphs are contained in it:
{F9197283}
And finally, Blend file thumbnails contain things like versions (used to create and minimum able to open), build hashes, flags, etc. This could of course be extended to include number of verts, faces, or whatever else we want to know about a blend before actually opening it.
{F9254222}