首页 > 解决方案 > 旋转的图片不显示在烧瓶中

问题描述

原始图片上传并存储在一个目录中,然后显示在一个html页面中。路线是

@mod.route('/profile', methods=['GET'])
@login_required
def profile():
    form = UpdateProfileForm()
    if request.method == 'GET':
        form.username.data = current_user.username
        form.country.data = Paises.query.all()
        form.telephone.data = current_user.telephone
    image_file = url_for('static', filename='profile_pics/' + current_user.image_file)
    return render_template('profile.html', form=form, image_file=image_file)

当有一个旋转90度的按钮时,它会在网页中显示图片。下图也显示了目录中的图片

在此处输入图像描述

转动图片的按钮调用路线和功能是

    path = 'static/profile_pics/'+filename
    i = Image.open(path)
    y, z = i.size
    i2 = i.rotate(90, expand=1)
    i2.save(path)

问题是在文件资源管理器中图片正确转动,在烧瓶网页中它仍然加载为原始图片。

在此处输入图像描述

感谢您的帮助

标签: pythonhtmlpython-3.xflaskflask-sqlalchemy

解决方案


您是否重新启动了 Flask 应用程序?清除浏览器的缓存也可以。


推荐阅读