Change material texture by loading an external .png file with Python I'm trying to change the texture of an object by changing the .png texture image I'm loading from an external folder. 

When using the Blender interface, all I need to do is going to the image tab in texture and open the file I want:



then



The changes are then operated automatically.

How would I go about to do the same in Python?

I have read other stackexchange answers to similar questions but I'm not sure to what extent they apply to my situation.
Let's say I have a plane with an image texture called leaf1.png and I want to change the texture to leaf2.png.

If I hover my mouse over the source area, I can see some text at the bottom of the tooltip that says how to access that data with python. Like this:



From this, I know that I can access this with python using bpy.data.images['leaf1.png'].filepath

So to change the image source with python, I do:

import bpy

bpy.data.images['leaf1.png'].filepath = 'path/to/leaf2.png'