在HTTP响应中返回图像 [英] Return image in HTTP response

查看:52
本文介绍了在HTTP响应中返回图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

计算散点图后

plt.scatter(...)

我可以使用

plt.show()

但是,我希望使用诸如savefig()之类的函数来保存该图,该函数将图像存储在变量而不是文件中,然后在Django Web框架中以content/png的形式在http响应中返回该变量

However, I wish to save the plot with some sort of function like savefig() which store the image in a variable instead of a file, then return the variable in http response as content/png in django web framework

推荐答案

进一步搜索后,我发现

After further searching, I found Returning MatPotLib image as string

此解决方案解决了我的问题.谢谢大家的帮助.

This solution solved my problem. Thank you everyone for the help.

这篇关于在HTTP响应中返回图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆