soja_resize_image.py 文件源码

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

项目:soja_box 作者: iTaa 项目源码 文件源码
def resize_image(img_path, mini_size=480, jpeg_quality=80):
    """
    ??image
    :param img_path: image???
    :param mini_size: ??????
    :param jpeg_quality: jpeg?????
    """
    org_img = cv2.imread(img_path)
    img_w = org_img.shape[0]
    img_h = org_img.shape[1]
    if max(img_w, img_h) > mini_size:
        if img_w > img_h:
            img_w = mini_size * img_w // img_h
            img_h = mini_size
        else:
            img_h = mini_size * img_h // img_w
            img_w = mini_size
    dist_size = (img_h, img_w)
    r_image = cv2.resize(org_img, dist_size, interpolation=cv2.INTER_AREA)
    params = [cv2.IMWRITE_JPEG_QUALITY, jpeg_quality]
    img_name = img_path + '_New.jpg'
    cv2.imwrite(img_name, r_image, params=[cv2.IMWRITE_JPEG_QUALITY, params])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号