Skip to content

Instantly share code, notes, and snippets.

@Pullusb
Created November 29, 2015 02:17
Show Gist options
  • Save Pullusb/9cf66e0c3eaf948e32c2 to your computer and use it in GitHub Desktop.
Save Pullusb/9cf66e0c3eaf948e32c2 to your computer and use it in GitHub Desktop.
blenderSB delete images from blend if no user or force delete
#removes images with no users
import bpy
images = bpy.data.images
U = 0
NU = 0
print (10*'-')
print ("total image before", len(bpy.data.images))
for i in images:
if not i.users:
NU += 1
print (i.name, 'removed')
images.remove(i) #remove image
else:
U += 1
if U == len(bpy.data.images):
print ("all", U, "image used")
else:
print ("total image now", len(bpy.data.images))
print ("used", U)
print ("unused deleted", NU)
'''
#forcekill by name
for i in images:
if i.name.startswith('sauce'):
i.user_clear() #set user to zero
i.remove(i) #remove image
'''
'''
#simple version
for i in images:
if not i.users:
i.remove(image)
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment