89
$\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$
0

6 Answers 6

98
$\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$
4
  • 7
    $\begingroup$ "You can do this quickly with Ctrl + Shift + O" make sure to run a Ctrl + S first. $\endgroup$
    – wchargin
    Aug 11, 2013 at 20:53
  • 5
    $\begingroup$ Is there no way to delete the data without reopening the file? $\endgroup$
    – Justin
    Jul 9, 2014 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$ Dec 19, 2014 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$ Dec 19, 2014 at 13:04
30
$\begingroup$

For 2.8x

In the outliner look for Orphan Data. Unused images will show up there. Select and delete:

enter image description here

For Previous versions:

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$
2
  • $\begingroup$ This saved me and preferable when there are many files to delete. Thank you. (works for Blender 3.2 as well) $\endgroup$
    – ofekp
    Jul 26, 2022 at 12:42
  • $\begingroup$ Thank you! This still works in Blender 3.6.2. $\endgroup$ Sep 6, 2023 at 1:12
17
$\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$
1
  • $\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$ Jun 12, 2017 at 6:48
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$
2
  • 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, 2018 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, 2018 at 13:52
0
$\begingroup$

The easiest method to do this that doesn't require a reopen is going to File-->Clean up-->Unused Data-Blocks.

$\endgroup$
0
$\begingroup$

Easy way I found was to select the objects you want, then copy them even lights. open another Blender version and paste them into that. Close the original blender file and save the new files over the old one. Now the older file name is saved with the new file and only the mesh/ with Materials and images you copied.

$\endgroup$

You must log in to answer this question.

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