def obj_image_load(context_imagepath_map, line, DIR, recursive, relpath):
"""
Mainly uses comprehensiveImageLoad
But we try all space-separated items from current line when file is not found with last one
(users keep generating/using image files with spaces in a format that does not support them, sigh...)
Also tries to replace '_' with ' ' for Max's exporter replaces spaces with underscores.
"""
filepath_parts = line.split(b' ')
image = None
for i in range(-1, -len(filepath_parts), -1):
imagepath = os.fsdecode(b" ".join(filepath_parts[i:]))
image = context_imagepath_map.get(imagepath, ...)
if image is ...:
image = load_image(imagepath, DIR, recursive=recursive, relpath=relpath)
if image is None and "_" in imagepath:
image = load_image(imagepath.replace("_", " "), DIR, recursive=recursive, relpath=relpath)
if image is not None:
context_imagepath_map[imagepath] = image
break;
if image is None:
imagepath = os.fsdecode(filepath_parts[-1])
image = load_image(imagepath, DIR, recursive=recursive, place_holder=True, relpath=relpath)
context_imagepath_map[imagepath] = image
return image
评论列表
文章目录