Blazingly fast preview loads. Images of arbitrary size. bpy.utils.previews drop-in replacement

Hey all,

We created a new Python library for Blender called 3DN BIP or 3D Ninjas Blender Image Preview. It allows blazingly fast preview loads in Blender. Furthermore, it can load preview images of arbitrary size. It operates as an bpy.utils.previews drop-in replacement and does all the heavy lifting for you.

Give it a spin: https://github.com/3dninjas/3dn-bip

We are looking forward to your feedback, proposals and improvements.

Niklas

22 Likes

If I understand well, this is a solution that will allow to speed up the generation of thumbnails for an example in various types of addons that use this type of functionality?

When you load multiple preview images in the Blender UI, it can sometimes take several seconds for them to load completely. With our library, preview images are loaded in milliseconds. Developers can use the library for their addons. The library is especially appealing if you offer a selection of assets and show preview images for them.

2 Likes

Does it work also for regular previews in the File browser window? I mean, if I enable the addon will it help when opening a folder full of images (jpg, exr, png, tif, etc) in the file browser, say to choose a texture for a shader?

Interesting idea. I don’t know if that is possible w/o modifying Blender itself. But we will have a look at it.

Currently, 3DN BIP is an embeddable library for add-on developers. They can copy the folder into their add-on and use the library instead of bpy.utils.previews.

Ok thanks.
I took a look and figure out what this library does. Nice. Fast browser previews would be nice too since when you open a crowded folder the lag is annoiyng, and the previews somtimes are useless because they’re too small

in that case why dont you directly write a patch and apply? so blender uses your superiour library by default.

Stuff like this is really amazing. Great work guys !

4 Likes

KIT OPS is using 3DN BIP now. See for yourself!

(credits to @bonjorno7 for the 3DN BIP code and @thefauxrogue for the documentation and testing)

6 Likes

Brush Manager is using 3DN BIP now. See for yourself!

1 Like

Graswald is using 3DN BIP and our new Asset Browser now. See for yourself!

4 Likes

So cool! The thumbnails always loaded slow and I thought it was my PC thanks for creating this library I am sure it will improve a lot of addons!

2 Likes

Cool! :slight_smile: We would be delighted if as many addon developers as possible were made aware of the library. Please help us to spread the word! :slight_smile:

2 Likes

Thanks for developing this! I also with you would write a patch for Blender to use this natively. I have big libraries of textures and it would be amazing if the images were generated as fast as with your library. Great work!

1 Like

I just learned from @franMarz that https://github.com/SavMartin/TexTools-Blender is using BIP as well! Awesome! :heart: (not released yet, but you can grab it from the master branch).

3 Likes

From what I understand, it is possible to convert an image with a .jpg, .jpeg or .png extension to .bip.
But is it possible to save a rendered image from data.images directly to .bip ?

There is no direct functionality for that.

I am not 100% sure, but I believe it is possible to extract the necessary data via https://docs.blender.org/api/current/bpy.types.Image.html#bpy.types.Image.pixels and https://docs.blender.org/api/current/bpy.types.Image.html#bpy.types.Image.size. It still needs to be converted from float to bytes (0-255) and RGBA if it isn’t RGBA yet.

The BIP format is pretty simple. See here: https://github.com/3dninjas/3dn-bip/blob/main/bip_converter/t3dn_bip_converter/convert.py#L42-L52.

@bonjorno7 or @thefauxrogue might be able to help if they have time to spare.

Thanks for the answer but the probleme with image from render resuilt is that the image ahs no data yet.
So I guess the only solution is to save the rendering as a jpeg or png and then convert the image to .bip.

If you want to avoid being dependent on Pillow, you could use https://raw.github.com/drj11/pypng/main/code/png.py to read the rendered PNG and save BIP according to the format linked in my previous post. PyPNG might be slow, though. Be aware that you need to flip top to bottom, and you need premultiplied alpha (https://github.com/3dninjas/3dn-bip/blob/main/bip_converter/t3dn_bip_converter/convert.py#L33-L34).

I don’t mind using Pillow at all. I even wonder why it is not part of the basic Blender modules :thinking:. It’s just that I would have liked to be able to save the renders directly as .bip instead of .jpeg or .png. But it doesn’t matter, I think the user won’t see anything when generating the thumbnails.
Anyway, nice work, it loads the images in a flash :+1:.

1 Like

Just wrote a solution for it

3 Likes