nested_layers.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:pytoshop 作者: mdboom 项目源码 文件源码
def _determine_channels_and_depth(layers, depth, color_mode):
    # type: (List[Layer], Optional[int], int) -> Tuple[int, int]

    num_channels = 0
    for image in _iterate_all_images(layers):
        if (image.color_mode is not None and
                image.color_mode != color_mode):
            raise ValueError("Mismatched color mode")
        for index, channel in image.channels.items():
            if np.isscalar(channel):
                continue
            num_channels = max(num_channels, index + 1)
            channel_depth = channel.dtype.itemsize * 8
            if depth is None:
                depth = channel_depth
            elif depth != channel_depth:
                raise ValueError("Different image depths in input")

    if num_channels == 0 or depth is None:
        raise ValueError("Can't determine num channels or depth")

    return num_channels, depth
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号