ok, i have a php file that retrieves images from a db, and outputs them to the browser, which is fine. however i decided to use modrewrite so that forums are happy with the 'normal' urls, at the same time i'm watermarking images.
there is 1 little problem, when the images are linked on a forum, they show up fine, such as this:

however, when you try accessing http://www.servfiles.com/1071/ directly in anything BUT IE it's gibberish, can anyone help?
thanks
here's kinda some code:
//[...]
function watermark($savedname, $origname) {
$imagesource = $origname;
$filetype = substr($imagesource,strlen($imagesource)-4,4);
$filetype = strtolower($filetype);
if($filetype == ".gif") $image = @imagecreatefromgif($savedname);
if($filetype == ".jpg") $image = @imagecreatefromjpeg($savedname);
//if($filetype == ".png") $image = @imagecreatefrompng($savedname);
if (!$image) die();
$watermark = @imagecreatefromgif('images/watermark.gif');
$imagewidth = imagesx($image);
$imageheight = imagesy($image);
$watermarkwidth = imagesx($watermark);
$watermarkheight = imagesy($watermark);
$startwidth = 10; //(($imagewidth - $watermarkwidth)/2);
$startheight = $imageheight - $watermarkheight - 10; //(($imageheight - $watermarkheight)/2);
imagecopy($image, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight);
if($filetype == ".gif") imagejpeg($image);
if($filetype == ".jpg") imagejpeg($image);
if($filetype == ".png") imagepng($image);
imagedestroy($image);
imagedestroy($watermark);
}
//[...]
//WATERMARK, IF IMAGE FROM ABOVE CHECK
$filetype = substr($origname,strlen($origname)-4,4);
$filetype = strtolower($filetype);
if($result) {
if($filetype == ".jpg" || $filetype == ".gif") { //$filetype == ".gif" || || $filetype == ".png"
watermark($savedname, $origname);
}
}
//[...]
//THE SOURCE OF THE FILE GRABBED FROM THE SERVER, SKIP IF IMAGE
if($filetype != ".gif") {
if($filetype != ".jpg") {
//if($filetype != ".png") {
//TYPE OF FILE TO BE OUTPUTTED
header($type);
//THE NAME OF THE FILE TO BE DOWNLOADED
header($origname);
readfile($savedname);
//}
}
}