As another option, you could, in theory, use mime_magic or the new fileinfo or I think there's a GD function to "guess" at the type... Personally, I think your first mistake was putting the image into the DB at all. Unless you're the CIA doing pixel comparisons actually in SQL stored procedures or something. :-) That particular horse has been beaten to death on this list, so search the archives for more on storing images in DB versus filesystem. On Sun, February 25, 2007 1:31 pm, Alain Roger wrote: > Hi, > > I previously sent email about process how to retrieve and save > pictures in > postgreSQL DB. > > Now i know how to save them in DB, however i would like to know how > can i > retrieve the pictures and display them without knowing the picture > extension > ? > i mean that in my DB i have GIFs, JPGs pictures. > > 1. My following code display without problem JPEG picture but what > about GIF > ? > 2. How can i display picture without using ==> header('Content-type: > image/jpeg'); Because this must be before displaying pictures. > 3. what should i do if i want to display several types of pictures in > the > PHP page ? > > My code : > > <?php > > $dbconn = pg_connect($conn_string) or die('Could not connect: ' . > pg_last_error()); > > $res = pg_query("SELECT * FROM immense.photo where photo_id=20"); > $raw = pg_fetch_result($res, 'photo_image'); > if (!$res) > { > echo "An error occured.\n"; > exit; > } > else > { > header('Content-type: image/jpeg'); > echo pg_unescape_bytea($raw); > } > > // Closing connection > pg_close($dbconn); > > ?> > > -- > Alain > ------------------------------------ > Windows XP SP2 > PostgreSQL 8.1.4 > Apache 2.0.58 > PHP 5 > -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php