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()