import bpy
def hex_to_rgb(value):
    gamma = 2.05
    value = value.lstrip('#')
    lv = len(value)
    fin = list(int(value[i:i + lv // 3], 16) for i in range(0, lv, lv // 3))
    r = pow(fin[0] / 255, gamma)
    g = pow(fin[1] / 255, gamma)
    b = pow(fin[2] / 255, gamma)
    fin.clear()
    fin.append(r)
    fin.append(g)
    fin.append(b)
    return tuple(fin)
bpy.ops.wm.open_mainfile(filepath='C:/Users/matth/Documents/GitHub/website/rendering/avatar.blend')
bpy.data.objects['Head'].select = True
bpy.data.materials['Head'].diffuse_color = hex_to_rgb('#ffffff')
bpy.data.materials['Face'].diffuse_color = hex_to_rgb('#ffffff')
bpy.data.objects['Left Arm'].select = True
bpy.data.objects['Left Arm'].active_material.diffuse_color = hex_to_rgb('#ffffff')
bpy.data.objects['Torso'].select = True
bpy.data.objects['Torso'].active_material.diffuse_color = hex_to_rgb('#ffffff')
bpy.data.objects['Right Arm'].select = True
bpy.data.objects['Right Arm'].active_material.diffuse_color = hex_to_rgb('#ffffff')
bpy.data.objects['Left Leg'].select = True
bpy.data.objects['Left Leg'].active_material.diffuse_color = hex_to_rgb('#ffffff')
bpy.data.objects['Right Leg'].select = True
bpy.data.objects['Right Leg'].active_material.diffuse_color = hex_to_rgb('#ffffff')

face_Image = bpy.data.images.load(filepath = 'C:/Users/matth/Documents/GitHub/website/rendering/global/defaultFace.png')
bpy.data.textures['Face'].image = face_Image
shirt_Image = bpy.data.images.load(filepath = 'C:/Users/matth/Documents/GitHub/website/rendering/global/0.png')
bpy.data.textures['Shirt'].image = shirt_Image
bpy.data.textures['ShirtR'].image = shirt_Image
bpy.data.textures['ShirtL'].image = shirt_Image
pants_Image = bpy.data.images.load(filepath = 'C:/Users/matth/Documents/GitHub/website/rendering/global/95f7caf82b3b5f0e43cdc04a9fa4eb8e.png')
bpy.data.textures['PantsR'].image = pants_Image
bpy.data.textures['PantsL'].image = pants_Image
for obj in bpy.data.objects:
    obj.select = False
    bpy.ops.object.select_all(action='SELECT')
bpy.ops.view3d.camera_to_view_selected()
scene = bpy.context.scene
scene.render.image_settings.file_format = 'PNG'
scene.render.filepath = 'C:/xampp21/htdocs/marketplace/avatars/ffc3d6cedb170c0d080c4729739b2f15.png'
bpy.ops.render.render(write_still = 1)