Ejemplo n.º 1
0
    def _image_load(path):
        import bpy

        if convert_callback:
            path = convert_callback(path)

        try:
            image = bpy.data.images.load(path)
        except RuntimeError:
            image = None

        if verbose:
            if image:
                print("    image loaded '%s'" % path)
            else:
                print("    image load failed '%s'" % path)

        # image path has been checked so the path could not be read for some
        # reason, so be sure to return a placeholder
        if place_holder and image is None:
            image = _image_load_placeholder(path)

        if image:
            if relpath is not None:
                # make relative
                from bpy.path import relpath as relpath_fn
                image.filepath_raw = relpath_fn(path, start=relpath)

        return image
Ejemplo n.º 2
0
    def _image_load(path):
        import bpy

        if convert_callback:
            path = convert_callback(path)

        # Ensure we're not relying on the 'CWD' to resolve the path.
        if not os.path.isabs(path):
            path = os.path.abspath(path)

        try:
            image = bpy.data.images.load(path, check_existing)
        except RuntimeError:
            image = None

        if verbose:
            if image:
                print("    image loaded '%s'" % path)
            else:
                print("    image load failed '%s'" % path)

        # image path has been checked so the path could not be read for some
        # reason, so be sure to return a placeholder
        if place_holder and image is None:
            image = _image_load_placeholder(path)

        if image:
            if force_reload:
                image.reload()
            if relpath is not None:
                # make relative
                from bpy.path import relpath as relpath_fn

                # can't always find the relative path
                # (between drive letters on windows)
                try:
                    filepath_rel = relpath_fn(path, start=relpath)
                except ValueError:
                    filepath_rel = None

                if filepath_rel is not None:
                    image.filepath_raw = filepath_rel

        return image
Ejemplo n.º 3
0
    def _image_load(path):
        import bpy

        if convert_callback:
            path = convert_callback(path)

        # Ensure we're not relying on the 'CWD' to resolve the path.
        if not os.path.isabs(path):
            path = os.path.abspath(path)

        try:
            image = bpy.data.images.load(path, check_existing=check_existing)
        except RuntimeError:
            image = None

        if verbose:
            if image:
                print("    image loaded '%s'" % path)
            else:
                print("    image load failed '%s'" % path)

        # image path has been checked so the path could not be read for some
        # reason, so be sure to return a placeholder
        if place_holder and image is None:
            image = _image_load_placeholder(path)

        if image:
            if force_reload:
                image.reload()
            if relpath is not None:
                # make relative
                from bpy.path import relpath as relpath_fn
                # can't always find the relative path
                # (between drive letters on windows)
                try:
                    filepath_rel = relpath_fn(path, start=relpath)
                except ValueError:
                    filepath_rel = None

                if filepath_rel is not None:
                    image.filepath_raw = filepath_rel

        return image