On Mon, 2007-03-05 at 10:16 -0500, Mark wrote: > Alain Roger wrote: > > > Hi, > > > > It's amazing that my previous post has raised so much consideration about > > the fact to store or not pictures into DB. > > And yet you ask again!? Did you not learn? No good can come from this > question. He didn't care about the debate. He is already using a database and wants to display the images. I'm sure he learned plenty, but not what he wanted to learn. I'd say the most important outcome of the side-track debate was to clarify that it depends on what you are working with, what you are doing, what your tolerance is for various types of solutions, and where those tolerances lie. An important thing we also learned, is that while filesystem storage is often the better solution, it is not always the best solution, especially when factoring in such things as convenience and simplicity. > > However, none of those posts answered to my question... How can i retrieve > > and display those pictures to my PHP pages ? > > > > Basically, on my PHP page I have some texts and I would like to extract > > from DB the pictures to display. > > Therefore, set the header to mine JPEG or GIF does not allow to have text > > also. > > This is another problem with images in databases, unlike text or data which > can be incorporated into the HTML output stream, an image needs to be its > own file. Image doesn't need to be it's own file, if it did then it would be forced to be on the filesystem, since we know it can be in a database instead, it thus follow it does not need to be it's own file... Ah but you are going to say "but it needs it's own script to access the image!" but that is not so, since a front end controller style script could easily contain the code to display an image with a little switch statement. Either way, you need a script wrapped around serving images from the filesystem if those images need to be protected by your site's authentication. Thus the point is completely moot. > You will have to hit the database twice. Once to render the page, and again > to render the image. > > To render the image you need to query the database and send the data back on > its own, but before you do, you have to set the content type header to > jpeg, gif, or whatever. > > This is why I say image data does not belong in the database. Boooooooooooooooooring. Belongs wherever the developer or the business requirements want to store it. Once again, you will need to set the content type header anyways if you have wrapped the image serving in your site's authentication checks -- whether it resides on the filesystem, in the database, or in a dark place where the sun don't shine. > > So please, how can i do to display pictures from DB, when my PHP page also > > include texts and other images (from filesystem) ? > > > > In fact i would like to do something like a thumbnail... > > You will need to repeat the same steps outlined above, but use image > manipulation utilities to reduce the image. Again, that's why you store > images in files and not in the database. Wrong again. Can pull the image directly into memory from the retrieved database field. Can then convert it to an image resource using imagecreatefromstring(). Can manipulate the image directly in memory using the image manipulation functions. And finally, can directly flush the image to the browser without ever having touched the filesystem manually. Filesystem is not a necessity. Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php