I have a script which i use to resize images to a certain size. At the same time this image attatches a watermark to the image. However I'm having problems with the colouring.
At present everything resizes beautifully and the watermark is attached no problem. However the colours are all screwed up?! It appears that there are very few colours in the out put image.
What si wrong with ym code? Is there soemthing I'm missing out?
Thanks in advance.
<?php
$src = $_GET['src'];
// create and return a thumbnail version of a jpg image
// $src is passed in URL
// set up height and width of the created thmbnail
$width = $_GET['x'];
$height = $_GET['y'];
// read in the passed image
// if it is a gif deal with it
if (substr($src,-3) == "gif") {
$im = imagecreatefromgif ("$src"); // Attempt to open
} else {
$im = imagecreatefromjpeg ("$src"); // Attempt to open
}
// create a blank image of the required size
$new = imagecreate ($width, $height);
// copy a resied version of the original to the new image
imagecopyresized($new,$im,0,0,0,0,$width,$height,
imagesx($im),imagesy($im));
// apply the watermark
$watermark = "../../graphics/watermark.gif";
$logoImage = ImageCreateFromGIF($watermark);
$logoW = ImageSX($logoImage);
$logoH = ImageSY($logoImage);
$posW = $width-$logoW;
$posH = $height-$logoH;
imagecopy($new, $logoImage, $posW, $posH, 0, 0, $logoW, $logoH);
// output header and file
header ("content-type: image/jpeg");
imagejpeg ($new);
// clear the image buffers
imagedestroy ($im);
imagedestroy ($new);
?>