67
$\begingroup$

I'm creating a model for a 3D game that will eventually be exported using a custom Python script. This model makes heavy use of UV textures.

However, the project now references a bunch of images that are not used by any objects in the project. Example:

enter image description here

I don't want the first two, or the red_bubble.png image. However, I have no idea how to remove them from the project. Selecting one of them reveals that there are "2 users of the data" although I am not using it anywhere.

How can I get rid of these excess images?

$\endgroup$
77
$\begingroup$

If you have an image (or other piece of data, such as a material) you can force remove all users by Shift clicking on the X next to it's name. This will "mark" the data for removal upon closing the file.

After you force remove the data, you'll need to reopen the file in order for the data to be removed. You can do this quickly by saving the file with CtrlS and then opening it with CtrlShiftO and selecting the file.

$\endgroup$
  • 6
    $\begingroup$ "You can do this quickly with Ctrl + Shift + O" make sure to run a Ctrl + S first. $\endgroup$ – wchargin Aug 11 '13 at 20:53
  • 3
    $\begingroup$ Is there no way to delete the data without reopening the file? $\endgroup$ – Justin Jul 9 '14 at 16:49
  • 2
    $\begingroup$ I do this much times, but my image still keeps there. As I imported it, it appears to disable me from saving as runtime game!!! $\endgroup$ – Adrians Netlis Dec 19 '14 at 12:58
  • 1
    $\begingroup$ When I press that X button, that image file does not appear 0 on side. Is there way to change link of that image? It locks me all the time:( $\endgroup$ – Adrians Netlis Dec 19 '14 at 13:04
13
$\begingroup$

if you want to do it via code, you could take a couple of approaches:

this removes all images in the blender file:

import bpy

# iterate over all images in the file
for image in bpy.data.images:

    # don't do anything if the image has any users.
    if image.users:
        continue

    # remove the image otherwise
    bpy.data.images.remove(image)

You also have the option to make this into a method that you can just pass the image to that you want to delete:

def clean_data_block(block):
    # iterate over every entry in the data block
    for data in block:

        # if the data block has any users, don't do anything
        if data.users:
            continue

        # otherwise remove the data block
        block.remove(data)

in this case you would clean the images that were not used by using:

clean_data_block(bpy.data.images)
$\endgroup$
  • $\begingroup$ I've tried this running the script inside a text editor in Blender, however it won't get rid of ones like these: bpy.context.area.type = 'CONSOLE' Path 'C:\Users\Richard\Documents\makehuman\v1\exports\textures\classicshoes_texture_diffuse.png' cannot be made relative $\endgroup$ – Richard Griffiths Jun 12 '17 at 6:48
4
$\begingroup$

You can do that by going to Outliner, then chose to display Blender File. enter image description here

Then right clicking on the image you want to remove and pressing delete. enter image description here

$\endgroup$
1
$\begingroup$

Removing the "users" of the image may not be sufficient, e.g. after doing the steps listed in the selected answer and even deleting the image file, image Stone texture.jpg was still used by an also unused texture:

enter image description here

If the selected answer method doesn't remove the image, then you may try to also click the "X" of the texture which has been linked to the image at some point.

The logic behind this is obscure to me. After breaking the parenting links between "users" of the image and the image, the texture shouldn't list it as a child, but it does.

The convoluted "node-based" design of Blender is indeed not user-friendly.

$\endgroup$
  • 1
    $\begingroup$ Deleting the image file can not and will not tell anything Blender as it can't know what were you doing with files in OS. Removing with Shift+X will remove the datablock on which Shift+X was executed. Image file in this case is another datablock. Using Purge All you can do that without reload, but in 2 steps. $\endgroup$ – Mr Zak Jun 9 '18 at 11:15
  • $\begingroup$ @MrZak: Thanks for the additional explanations, the main point however is that it worked for me to unlink a reluctant image node, as explained. $\endgroup$ – mins Jun 9 '18 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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