Rotate UV by specific angle e.g. 30deg in Python script in backgroud mode I am trying to figure out how to rotate UVs in mesh while Blender is in Background mode without windows, so some parts are not accessible.

Right now I am using bpy.ops.mesh.uvs_rotate() > this works, but it is just in 90 degrees, so I am not able to set UV rotation in specific degree.

bpy.ops.object.editmode_toggle()
bpy.ops.uv.smart_project(angle_limit=66, island_margin=0, user_area_weight=0)
bpy.ops.uv.reset()
bpy.ops.mesh.uvs_rotate()


On this http://blenderartists.org/forum/showthread.php?267997-Rotate-the-uv-s-of-a-selected-object-instead-of-the-object-itself there is written, that I should use bpy.ops.transform.rotate(value=math.radians(45)) while being in bpy.context.area.type = 'IMAGE_EDITOR'.

The problem with this is that when I run blender like 

blender  --python-console --background

&gt;&gt;&gt; import bpy
&gt;&gt;&gt; bpy.context.area.type
Traceback (most recent call last):
  File "&lt;console&gt;", line 1, in &lt;module&gt;
AttributeError: 'NoneType' object has no attribute 'type'
&gt;&gt;&gt; 


It seems that object bpy.context.area.type is not possible to change, because it does not exist. In overall our code, we try to not use this. But it case of UV I am not able to figure out how to do it without this. I know that there is a lot of problems with these context.

So how should I rotate UV without context. Is it possible? Or is there a different way how to rotate image on separate object by specific degree?
you can do the math yourself , if nothing is available :
rotate all the points around the center of the image (0.5, 0.5)

import bpy
from math import cos, sin, radians


def make_rotation_transformation(angle, origin=(0, 0)):
    cos_theta, sin_theta = cos(angle), sin(angle)
    x0, y0 = origin    
    def xform(point):
        x, y = point[0] - x0, point[1] - y0
        return (x * cos_theta - y * sin_theta + x0,
                x * sin_theta + y * cos_theta + y0)
    return xform


ob = bpy.context.object
rad = radians(30)
anchor = (0.5, 0.5)

rot = make_rotation_transformation(rad, anchor)

UVmap = ob.data.uv_layers.active
for v in ob.data.loops :
     UVmap.data[v.index].uv = rot(UVmap.data[v.index].uv ) 


the make_rotation_transformation  is from this answer   by @200-success