ajicles Posted July 18, 2010 Share Posted July 18, 2010 I have my script that was working before I added a function to error trap different file extensions and I got an error and I can't figure it out. And I was wondering how I could just add the watermark to the image and just save it. Thanks ~AJ <?php $filename = @$_GET['image']; $filename = 'images/'.$filename.''; $ext = end(explode('.', $filename)); $ext = strtolower($ext); function HEADER(&$ext){ if ($ext == 'png'){ header('Content-Type: image/png'); } elseif($ext == 'bmp'){ header('Content-Type: image/png'); } elseif($ext == 'jpeg'){ header('Content-Type: image/png'); } elseif($ext == 'jpg'){ header('Content-Type: image/png'); } elseif($ext == 'gif'){ header('Content-Type: image/png'); } else { echo 'I do not know that file extenstion '; } } function DEST(&$ext){ if ($ext == 'png'){ $dest = imagecreatefrompng($filename); } elseif($ext == 'bmp'){ $dest = imagecreatefrombmp($filename); } elseif($ext == 'jpeg'){ $dest = imagecreatefromjpeg($filename); } elseif($ext == 'jpg'){ $dest = imagecreatefromjpg($filename); } elseif($ext == 'gif'){ $dest = imagecreatefromgif($filename); } else { echo 'I do not know that file extenstion '; } } $watermark = 'watermark.gif'; DEST($ext); $src = imagecreatefromgif($watermark); list($width, $height, $type, $attr)=getimagesize($filename); $markwidth = 86; $markheight = 20; $opacity = 35; imagecopymerge($dest, $src, ($width-$markwidth)>>1, ($height-$markheight)>>1, 0, 0, $markwidth, $markheight, $opacity); header($IMG); imagegif($dest); imagedestroy($dest); imagedestroy($src); Quote Link to comment Share on other sites More sharing options...
Mchl Posted July 18, 2010 Share Posted July 18, 2010 There already is header function in PHP. You can't override it. Quote Link to comment Share on other sites More sharing options...
ajicles Posted July 18, 2010 Author Share Posted July 18, 2010 There already is header function in PHP. You can't override it. Thank you. I thought it won't over write if the name was upper case. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted July 18, 2010 Share Posted July 18, 2010 Variables are case-sensitive, functions aren't, so you need a unique name for them. Quote Link to comment Share on other sites More sharing options...
ajicles Posted July 19, 2010 Author Share Posted July 19, 2010 Variables are case-sensitive, functions aren't, so you need a unique name for them. ok, Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.