from PIL import Image
import unreal_engine as ue
from unreal_engine.classes import Texture2D

def rotate_selected_assets_data(degrees):
    for asset in ue.get_selected_assets():
        if asset.is_a(Texture2D):
            tex = ue.load_object(Texture2D, asset.get_path_name())
            data = tex.texture_get_data()
            size = (asset.Blueprint_GetSizeX(), asset.Blueprint_GetSizeY())

            img = Image.frombytes("RGB", size, data)
            img.show()
            out = img.rotate(degrees, expand=1)
            tex.texture_set_data(out.tobytes())

from PIL import Image
import unreal_engine as ue
from unreal_engine.classes import Texture2D

def rotate_selected_assets_data(degrees):
    for asset in ue.get_selected_assets():
        if asset.is_a(Texture2D):
            data = asset.texture_get_source_data()
            
            size = (asset.texture_get_width(), asset.texture_get_height())
           
            img = Image.frombytes('RGBA', size, bytes(data))
            
            out = img.rotate(degrees)

            asset.texture_set_source_data(out.tobytes())

            
            

rotate_selected_assets_data(45)

Update rotate_texture.py