Image resize but not save it. Show Viewport

i want to resize the image as it does bpy.ops.image.resize()
I found a way to change the size but the texture in the viewport does not change. How can I update the viewport so I can see the texture at a lower resolution?

import bpy
def testo ():
    sel_obj = [obj for obj in bpy.context.selected_objects  if obj.type == 'MESH']
    for x in sel_obj:
        mats = set(s.material for s in x.material_slots if s.material and s.material.use_nodes)
        for m in mats:
            nodes = m.node_tree.nodes
            
            all_texture_node = [n for n in nodes if isinstance(n, bpy.types.ShaderNodeTexImage)]
            for x in all_texture_node:
                node_image = x.image
                if node_image:
                    texture_name = node_image.name
                    
                    image_node = x
                    w = int ( image_node.image.size[0] / 2 )
                    h = int ( image_node.image.size[1] / 2 )
                
                    image_node.image.scale( w, h )
                    image_node.image.update()

bpy.ops.image.save_all_modified() is the missing link in your code

Two years have passed and in my opinion I somehow solved this problem)) But the option with saving did not suit me, since I do not want to apply the changed size

I faced the same problem today and your code helped alot. How did you solve it without saving. Please share

default_gl_texture_limit = bpy.context.preferences.system.gl_texture_limit
bpy.context.preferences.system.gl_texture_limit = ‘CLAMP_8192’
bpy.context.preferences.system.gl_texture_limit = default_gl_texture_limit

Try this. Implemented function in this addon