def get_hidden_image(tpath, bdata_name, force_reload=False, colorspace='sRGB'): if bdata_name[0] == '.': hidden_name = bdata_name else: hidden_name = '.%s' % bdata_name img = bpy.data.images.get(hidden_name) if tpath.startswith('//'): tpath = bpy.path.abspath(tpath) if img == None or (img.filepath != tpath): if tpath.startswith('//'): tpath = bpy.path.abspath(tpath) if not os.path.exists(tpath) or os.path.isdir(tpath): tpath = paths.get_addon_thumbnail_path('thumbnail_notready.jpg') if img is None: img = bpy.data.images.load(tpath) img.name = hidden_name else: if img.filepath != tpath: if img.packed_file is not None: img.unpack(method='USE_ORIGINAL') img.filepath = tpath img.reload() image_utils.set_colorspace(img, colorspace) elif force_reload: if img.packed_file is not None: img.unpack(method='USE_ORIGINAL') img.reload() image_utils.set_colorspace(img, colorspace) return img
def get_thumbnail(name): p = paths.get_addon_thumbnail_path(name) name = '.%s' % name img = bpy.data.images.get(name) if img == None: img = bpy.data.images.load(p) image_utils.set_colorspace(img, 'sRGB') img.name = name img.name = name return img