Delete all unused textures from Blender using Python
Remove all images with zero users from the blendfile:

import bpy

for img in bpy.data.images:
    if not img.users:
        bpy.data.images.remove(img)