Hello,

I'm working on a site and I want to make it so that different border colors can be found on different pages of my site (to match the different color schemes). Currently, every picture has a black border around it.

My images are this:

<img src="lib/resize.php?pic=../<?=$picpath?>&dim=50" border=0>

The script is:

Code:
<?php

$pic = $_GET['pic'];

$maxdim = $_GET['dim'];



if(!isset($_GET['color']))

	$color = '#000000';

else

	$color = $_GET['color'];

	

$color = substr($color, 1);

$r = hexdec(substr($color, 0, 2));

$g = hexdec(substr($color, 2, 2));

$b = hexdec(substr($color, 4, 2));



$ext = strtolower(end(explode('.', $pic)));

if ($ext == 'jpg' || $ext == 'jpeg') {

    $img = @imagecreatefromjpeg($pic);

} else if ($ext == 'png') {

    $img = @imagecreatefrompng($pic);

} else if ($ext == 'gif') {

    $img = @imagecreatefrompng($pic);

}





    # Get image size and scale ratio

    $width = imagesx($img);

    $height = imagesy($img);

    $scale = min($maxdim/$width, $maxdim/$height);





    # If the image is larger than the max shrink it

    if ($scale < 1) {

        $new_width = floor($scale*$width);

        $new_height = floor($scale*$height);

	}

	else{

		$new_width = $width;

		$new_height = $height;

	}

		



        # Create a new temporary image

        $tmp_img = imagecreatetruecolor($new_width, $new_height);

		$border_color = imagecolorallocate($tmp_img, $r, $g, $b);



        # Copy and resize old image into new image

        imagecopyresampled($tmp_img, $img, 0, 0, 0, 0,

                         $new_width, $new_height, $width, $height);

		$widthm1 = $new_width - 1;

		$heightm1 = $new_height - 1;

		imageline( $tmp_img, 0,0, $widthm1, 0, $border_color);

		imageline( $tmp_img, $widthm1, 0, $widthm1, $heightm1, $border_color);

		imageline( $tmp_img, $widthm1, $heightm1, 0, $heightm1, $border_color);

		imageline( $tmp_img, 0, $heightm1, 0, 0, $border_color);

        imagedestroy($img);

        $img = $tmp_img;





if($ext == "jpg")

{

 $ext = "jpeg";

}



header("Content-type: image/".$ext);

$functionname = "image" . $ext;

$functionname($img);

?>
How can I modify this script to make it so that not every image has a black border around it? I want to be able to change the border color based on the page the picture is on.

Sorry, I'm a bit new to this. Thanks in advance.