codecs.py 文件源码

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

项目:pytoshop 作者: mdboom 项目源码 文件源码
def decompress_zip_prediction(data,    # type: bytes
                              shape,   # type: Tuple[int, int]
                              depth,   # type: int
                              version  # type: int
                              ):       # type: (...) -> np.ndarray
    """
    Decompress zip (zlib) with prediction encoded data.

    Not supported for 1- or 32-bit images.

{}
    """
    if depth == 1:  # pragma: no cover
        raise ValueError(
            "zip with prediction is not supported for 1-bit images")
    elif depth == 32:
        raise ValueError(
            "zip with prediction is not implemented for 32-bit images")
    elif depth == 8:
        decoder = packbits.decode_prediction_8bit
    else:
        decoder = packbits.decode_prediction_16bit

    data = zlib.decompress(data)
    image = util.ensure_native_endian(
        decompress_raw(data, shape, depth, version))
    for i in range(len(image)):
        decoder(image[i].flatten())
    return image
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号