smilevector.py 文件源码

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

项目:dribbot 作者: dribnet 项目源码 文件源码
def resize_to_optimal(infile, scale_ratio, rect, outfile):
    image_array = imread(infile, mode='RGB')
    im_shape = image_array.shape
    h, w, _ = im_shape

    width = float(rect.right()-rect.left())
    scale_amount = (optimal_extent * scale_ratio) / width
    new_w = int(scale_amount * w)
    new_h = int(scale_amount * h)
    new_w = new_w - (new_w % 4)
    new_h = new_h - (new_h % 4)

    print("optimal resize of width {} and ratio {} went from {},{} to {},{}".format(width, scale_ratio, w, h, new_w, new_h))
    new_shape = (new_h, new_w)
    image_array_resized = imresize(image_array, new_shape)
    imsave(outfile, image_array_resized)
    return new_shape
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号