Question: How can one autogenerate a thumbnail for a .blend file with a custom resolution

TLDR: How does Blender generate a thumbnail of a .blend file?

Blender has a tool called "blender-thumbnailer", which file managers use to generate/fetch images (previews) of the .blend files. These previews are in a set reselution of 128x128, in some cases even smaller if the blender window was scaled in some way when saving the file.

Example of saved .blend file with

Above is an example of a .blend file which has been saved, and the thumbnail (preview) is successfully fetched by the program blender-thumbnailer by providing the following arguments:

blender-thumbnailer <input.blend> <output.png>

Example of auto thumbnail generation of file

Above is an example of a .blend file with a generated preview image of the 3D file. The same command, blender-thumbnailer, has been run on it. However the difference between the two thumbnails can be noted:

Saved .blend file has:

  • UI menu
  • Background rendered
  • Material view

Generated .blend file has:

  • No UI menu
  • No background rendered (white background, the same on all .blend files with generated thumbnail)
  • No material rendering

The saved .blend file is essentially a screenshot taken upon saving the file. That can be concluded by looking at the missing UI menu of the auto generated .blend file. The autogenerated thumbnail somehow generates the thumbnail in a background process, and I want to replicate that so I can have a custom resolution set for these thumbnails.

What I have attemped to autogenerate my own thumbnails for .blend files:

Using python and blenders API there are three operators I have tried to use

  1. bpy.ops.screen.screenshot This requires the .blend file to be open, which is neither optimal - or what I assume happens when blender-thumbnailer generates the preview

  2. bpy.ops.render.opengl Requires opengl, which can not be run as a background process

  3. bpy.ops.wm.previews_batch_generate I do not know how to save the output of this operation, and therefore don't know if this is a way to generate previews. Either way, there is no option (to my knowladge) of scaling the output to a custom resolution


1 Answer 1


If you want to replace a blend files thumbnail this is quite involved as you would need to add/update one of the chunks of data in an existing blend file.

Older versions of Blender included a Python script to extract previews from the blend file into PNG's (now this has been rewritten in C++), even so, the Python script could be used as a reference for accessing the thumbnail preview.

Check https://github.com/blender/blender/blob/v2.83.20/release/bin/blender-thumbnailer.py - which is a primitive blend file reader, you'll want to read the TEST BHead, it's data consists of an int32[2] for the image width,height followed by the RGBA image data (where each channel is a uint8_t).

You can replace the pixel information, or change the contents and re-write the blend file.

Blender has logic for reading/writing this, check on use of the BLEN_THUMB_MEMSIZE_FILE macro to see where that is handled.

Other considerations:

  • The TEST, BHead chunk may not exist and may need to be added.
  • Blend files may use ZSTD or GZip compression.
  • Blend files may be saved on 32 or 64bit systems (BHead4 or BHead8 in Blender's code).
  • Blend files specify their endian, checks for big/little endian files should be done.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .