models.py 文件源码

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

项目:exchange 作者: boundlessgeo 项目源码 文件源码
def convert_image(image, width, height):
    """
    resize the image to the correct size needed by the template.
    """
    name = image.name
    pio = Image.open(image)
    if width is None:
        img = resizeimage.resize_height(pio, height, validate=False)
    else:
        img = resizeimage.resize_cover(pio, [width, height], validate=False)
    new_image_io = BytesIO()
    img.save(new_image_io, format=pio.format)
    image.delete(save=False)
    image.save(
        name,
        content=ContentFile(new_image_io.getvalue()),
        save=False
    )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号