Using python, I remapped some images using image.user_remap(new_image)
. The images are assigned correctly, but the user count is wrong.
How can I force to check if an Image really has users without restarting the file?
Currently it is somewhat random which Images are image.users==1
and which don't. Some which are actually used return 0
and other which don't return 1
.
If I save the file like this and restart, actually being used images will be missing, leaving unassigned UV textures in my mesh. However, activating every Image will set image.users
to 1
, regardless of wether they really have users or not. This way image.users
will be correct after saving and restarting, but I need to rely on this data without restarting Blender.
Please see the attached file. After running the script, user counts will be wrong. Wrong Images will be deleted after restarting. https://www.dropbox.com/s/4jywkbwadnnqgl4/Test2.blend?dl=0
Here is a list that shows which images I wish to keep and remove.
Kept images
(old name new name)
CrackedSand2.tga.001 crackedsand2.tga
Desertrocku.tga Desertrocku.tga
Desertrocku2.tga.001 desertrocku2.tga
G3_Desert_Rock.tga G3_Desert_Rock.tga
G3_PlainSand_02.tga g3_plainsand_02.tga
G3_PlainSand_Blut.tga G3_PlainSand_Blut.tga
G3_PlainSand_Blut2.tga G3_PlainSand_Blut2.tga
ROCK6.tga ROCK6.tga
ROCK6u.tga ROCK6u.tga
SandDunesBig.tga SandDunesBig.tga
Removed images
G3_PlainSand_02.tga.001
G3_PlainSand_02.tga.002
Pattern: Remove ".001" etc. suffixes. Note that the case is supposed to be set to lower case for used images after line #20, but this fails to work correctly because the user count is wrong already.
if correct_index == -1: ...
#15elif index == correct_index: pass
# 16else: image.user_remap...
The result is different, but still not correct. The faces have the desired image assigned, but the user count ist wrong as before. Might this be a bug of the recently introduced user_remap function? Working with fake_users will be my last resort, but feels more like a hack. $\endgroup$