stop storing images in the db...store the path and file name instead...way easier, better db performance, no db bloat...
when showing the image, call the db for the path /filename and merely echo to the <img> tag:
echo "<img src="$resultfromDB.gif">";
hth
bastien