What is the best way in Etomite to display an image that is stored in a database table as a BLOB? I don't want to take the performance hit of (on every page hit) creating a file and then using <img src=file.jpg>
The php manual says "PHP can output image streams directly to a browser" when used with the GD Library. Is that the best way approach?
BTW, I do realize that most people store each image in a file and then store a link in a database table. I'd rather not do that if I don't have to, as my images are small enough to store in MySQL and not cause too much overhead.
Any help will be appreciated.
Display Images from Database Table
Started by jon, Jan 21 2008 03:31 AM
3 replies to this topic
#1
Posted 21 January 2008 - 03:31 AM
#2
Posted 21 January 2008 - 04:11 AM
Truth be told, you are taking a greater performance hit by storing the images in a MySQL database table... The added overhead of having to query the database for the proper record, abstracting the blob from the resultset, calling the GD library to generate the image into a displayable object, and returning that object to your Etomite code, complete with all the error handler logic, is much more resource consuming than just using an image tag within your markup... And that's not even taking into consideration the added complexities of putting the image into a MySQL blob in the first place... However, if you are up to the overall task then creatig the image and displaying it within Etomite should be a non-issue as that's just about the easiest part...
#3
Posted 21 January 2008 - 05:07 AM
As always, your help is very much appreciated. As you suggest, I will opt for file-based storage of images. I did not have the experience to realize what would have been involved with storing images in a database.
#4
Posted 21 January 2008 - 02:08 PM
jon, on Jan 21 2008, 12:07 AM, said:
As always, your help is very much appreciated. As you suggest, I will opt for file-based storage of images. I did not have the experience to realize what would have been involved with storing images in a database.
Always glad to help... What it boils down to is letting the server, whether Apache or any other flavor, do what it does best - locate and hand out files... Letting the server do this work will vastly improve the performance of your application as well as reducing the code overhead... If it ain't broke, why try making it so complex that it has more chances to break... Spend your time and efforts writing code that will make a greater impact on the site...
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users










