mbtiler.py 文件源码

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

项目:rio-rgbify 作者: mapbox 项目源码 文件源码
def _encode_as_webp(data, profile=None, affine=None):
    """
    Uses BytesIO + PIL to encode a (3, 512, 512)
    array into a webp bytearray.

    Parameters
    -----------
    data: ndarray
        (3 x 512 x 512) uint8 RGB array
    profile: None
        ignored
    affine: None
        ignored

    Returns
    --------
    contents: bytearray
        webp-encoded bytearray of the provided input data
    """
    with BytesIO() as f:
        im = Image.fromarray(np.rollaxis(data, 0, 3))
        im.save(f, format='webp', lossless=True)

        return f.getvalue()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号