utils.py 文件源码

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

项目:GulpIO 作者: TwentyBN 项目源码 文件源码
def resize_by_short_edge(img, size):
    if isinstance(img, str):
        img_path = img
        img = cv2.imread(img_path, cv2.IMREAD_ANYCOLOR)
        if img is None:
            raise ImageNotFound("Image read None from path ", img_path)
    if size < 1:
        return img
    h, w = img.shape[0], img.shape[1]
    if h < w:
        scale = w / float(h)
        new_width = int(size * scale)
        img = cv2.resize(img, (new_width, size))
    else:
        scale = h / float(w)
        new_height = int(size * scale)
        img = cv2.resize(img, (size, new_height))
    return img
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号