简短的答案是:如果图像很小并且没有很多,那么数据库中的Blob可能很好(更易于备份,控制访问,事务等).但是与文件系统相比,性能很差-这是一个折衷.大多数实际的应用程序(尤其是大型网站)都使用文件系统,但是在某些情况下使用blob是完全合理的. blob(或文件)将只是编码数据(JPG),它是完全相同的字节流.在Web应用程序中,您将使用img标签-如果要构建桌面GUI,请查看其具有用于显示图像的组件.如果您正在使用Blob,并且需要在Web应用程序中显示,则img标签的src将被设置为脚本/视图/等,该脚本/内容/返回的内容类型将设置为图像的mime类型(例如image/jpeg)和Blob的内容.I want to store the images related to a each person's profile in the DB and retrieve themwhen requested and save it as .jpg file - and display it to the users.How could I render the image data stored in the DB as an image and store it locally?? 解决方案 This StackOverflow Question is a good one to start with when figuring out whether to store images in a DB or on a filesystemStoring Images in DB - Yea or Nay?I have also written about the issues on my bloghttp://www.atalasoft.com/cs/blogs/loufranco/archive/2007/12/03/images-in-databases-part-i-what-to-store.aspxhttp://www.atalasoft.com/cs/blogs/loufranco/archive/2007/12/04/images-in-databases-part-ii-web-images-are-random-access.aspxhttp://www.atalasoft.com/cs/blogs/loufranco/archive/2009/04/28/document-storage-database-blobs-or-the-filesystem.aspxThe short answer is: if the images are small and there aren't a lot of them -- a blob in the DB is probably fine (easier to backup, control access, transactions, etc). But the performance is bad compared to the filesystem -- it's a tradeoff. Most real applications (and especially big websites) use the filesystem, but it's perfectly reasonable to use blobs in some cases.The blob (or file) is just going to be the encoded data (JPG) -- it's the exact same stream of bytes. In a web app, you would use an img tag -- if you are building a desktop GUI, look at what components it has for displaying images.If you are using a blob, and need to display in a web app, the src of the img tag will be set to a script/view/etc that returns a content-type set to the mime-type of the image (e.g. image/jpeg) and the content of the blob. 这篇关于使用Python从数据库存储和检索图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的.. 09-06 16:27