Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

With large projects that have hundreds of textures, it can be very difficult to deal with them in the UV image editor using the following little drop-down menu.
image data block menu

The best solution that I've come with so far is to modify the UV Image Editor code using some code from the Sculpt and Texture Paint section which is very helpful but it's still difficult to tell if something is in use and it has to be reopened every time something is selected and deleted.

(It now looks like the following in case anyone is interested. You can do this by menu-clicking the image icon next to New and Open then selecting edit source and changing the following line in

layout.template_ID(sima, "image", new="", open="") 

to be

*layout.template_ID_preview(sima, "image", new="", open="", rows=8, cols=16*)    

changed image menu

This question deals with deleting textures and it's what I already do. But it's time consuming and very difficult to find the unused textures when there are a couple hundred of them, especially if the drop down menu has to be reopened and searched for everyone one of them.

So my question is the this:
Is there a way to delete all the unused textures using a Python script?

I have found one script that does not work very well. Sometimes it does and sometimes it does not.
This gives the impression that there is something going on behind the scenes when it comes to how textures are considered to be in use.

By the way, I don't use Fake User or pack images so this may simplify things a bit.

share|improve this question
If the datablocks are unused, they should be cleared out when you reload the .blend.. – gandalf3 Jul 8 '14 at 9:08
The problem is having to reopen and search the menu over and over again since it closes when something is selected. Also, it's not always clear what needs to go just from looking. – MarcClintDion Jul 8 '14 at 9:26
I'm not sure I understand.. Couldn't you just save the .blend and re-open it? (Ctrl+S, then Ctrl+Shift+O 1) That should clear out all datablocks with no users. – gandalf3 Jul 8 '14 at 17:46
I do that but it does not work all the time. I've even tried deleting every last object from the scene, saving, then reloading it, but most of the textures were still there even though there were not any models. This works fine for removing materials but textures are really hard to get rid of. – MarcClintDion Jul 9 '14 at 2:18
I just tried what I said about deleting all the objects, then saving and reloading. Most, or all the textures were still there, but when I fully shutdown Blender and reloaded the empty scene then only 17 of the textures are still there. I guess this should be a bug report. (This is without using the posted script). When I ran the script, another 12 disappeared right away. 3 were loaded from Texture Paint and 2 were from a model that was not there. – MarcClintDion Jul 9 '14 at 23:57
up vote 10 down vote accepted

Remove all images with zero users from the blendfile:

import bpy

for img in
    if not img.users:
share|improve this answer
Do you know if anyone written an addon to have this option accessible right from the UV Image Editor? – Perrishnikov Aug 20 '15 at 15:55
How can I remove all texture without users OR with fake users? – The Poet Oct 25 '15 at 3:31
ID.use_fake_user – pink vertex Oct 27 '15 at 23:14
if not img.users or (img.users == 1 and img.use_fake_user): – pink vertex Oct 27 '15 at 23:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.