<?php

/*
    Watermark Script by Michelle Allen (poedgirl)
        to use this simply create an image called watermark.png
        with the transparent parts coloured magenta (255,0,255)
        and place the images you want into a folder called screenshots.
        Access the picture by going to pic.php?image=[imagename]
        NOTE: all pictures must be in PNG format to work
        
        Copyright 2004-2006 Michelle Allen
*/
    
extract($HTTP_GET_VARS);
    if (!
file_exists("screenshots/".$image)) {
        echo 
"file does not exist!";
    } else {
        if(
substr($image,strlen($image)-3) == "jpg") {
            
header("Content-type: image/jpeg");
                    
$imgsrc imagecreatefromjpeg("screenshots/".$image);
                    
$imgmark imagecreatefrompng("watermark.png");
                    
imagecolortransparent($imgmarkimagecolorallocate($imgmark2550255));

                    list(
$srcwidth$srcheight$srctype$srcattr) = getimagesize("screenshots/".$image);
                    list(
$markwidth$markheight$marktype$markattr) = getimagesize("watermark.png");

                    
imagecopymerge($imgsrc$imgmark$srcwidth $markwidth$srcheight $markheight00$markwidth$markheight50);
            
                    
imagejpeg($imgsrc,"",100);
                    
imagedestroy($imgsrc);
        } else {

            
header("Content-type: image/png");
            
$imgsrc imagecreatefrompng("screenshots/".$image);
            
$imgmark imagecreatefrompng("watermark.png");
            
imagecolortransparent($imgmarkimagecolorallocate($imgmark2550255));
        
            list(
$srcwidth$srcheight$srctype$srcattr) = getimagesize("screenshots/".$image);
            list(
$markwidth$markheight$marktype$markattr) = getimagesize("watermark.png");
        
            
imagecopymerge($imgsrc$imgmark$srcwidth $markwidth$srcheight $markheight00$markwidth$markheight50);
        
            
imagepng($imgsrc);
            
imagedestroy($imgsrc);
        }
    }
    
?>