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 space_image.py

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

to be

*layout.template_ID_preview(sima, "image", new="image.new", open="image.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.

  • 2
    $\begingroup$ If the datablocks are unused, they should be cleared out when you reload the .blend.. $\endgroup$
    – gandalf3
    Commented Jul 8, 2014 at 9:08
  • $\begingroup$ 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. $\endgroup$ Commented Jul 8, 2014 at 9:26
  • $\begingroup$ 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. $\endgroup$
    – gandalf3
    Commented Jul 8, 2014 at 17:46
  • $\begingroup$ 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. $\endgroup$ Commented Jul 9, 2014 at 2:18
  • 1
    $\begingroup$ Happily that's one of the things that's being refactored for 2.8 (some of it might even be in 2.78) $\endgroup$
    – gandalf3
    Commented Aug 4, 2016 at 2:09

2 Answers 2


Remove all images with zero users from the blendfile:

import bpy

for img in bpy.data.images:
    if not img.users:
  • $\begingroup$ Do you know if anyone written an addon to have this option accessible right from the UV Image Editor? $\endgroup$ Commented Aug 20, 2015 at 15:55
  • $\begingroup$ How can I remove all texture without users OR with fake users? $\endgroup$
    – RollRoll
    Commented Oct 25, 2015 at 3:31
  • $\begingroup$ ID.use_fake_user $\endgroup$ Commented Oct 27, 2015 at 23:14
  • 1
    $\begingroup$ if not img.users or (img.users == 1 and img.use_fake_user): $\endgroup$ Commented Oct 27, 2015 at 23:16

fix as 0 use ...press ctrl and delete " texture , material and others" and after, save your work

  • $\begingroup$ "Using Python". $\endgroup$
    – Shady Puck
    Commented Aug 2, 2016 at 9:03
  • 1
    $\begingroup$ Please expand your answer so it is clear what steps need to be taken. Also consider that the question asks for an answer using Python. $\endgroup$ Commented Aug 2, 2016 at 13:19

You must log in to answer this question.

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