Reloading texture with python not working I am trying to build a tool to bake textures from one UV layout to another via scripting but before baking all the textures must be loaded in blender.

I set the filepath to my image:

bpy.data.images["Image"].filepath = "/Users/John/image.jpg"


In texture panel I can see the source is set, but Can't Load Image is displayed

bpy.data.images["Image"].reload()


seems to have no effect. Only after manually clicking the reload button, the texture is refreshed. Any ideas how to reload the texture through Python, also I'm trying to run this headlessly if it matters.

Thanks!
Hi in addition to what J. Bakker said, here is some code that I used in TexTools addon to reload all images and remove unused ones.

import bpy

# Clean up unused images
for img in bpy.data.images:
    if not img.users:
        bpy.data.images.remove(img)

#Reload all File images
for img in bpy.data.images :
    if img.source == 'FILE' :
        img.reload()


Hope this helps,

renderhjs