negative resized image
<p>this is my script below which i use to re-size the images.  <p>My problem is that this script generates negative images (like negative films <b>[with only .png files]</b>) . Where/What is the problem ?</p> </p>

<p>I used GD library to re-size the images but I got same result.</p>

<pre><code>       $dir = "../images/sliderimages/";
       $photo = $_FILES['slid_image_upload']['name'];
       $tmp_name = $_FILES['slid_image_upload']['tmp_name'];
       $filename = $dir.$photo;
   $dir_thm = "../images/thm_sliderimages/";
   $thm_filename = $dir_thm.'thm_'.$photo;

       /************Resizing the image***************/


       $size = getimagesize($tmp_name);

       $width = $size[0];

       $height = $size[1];

       $newheight = 200;
       $newwidth = 420;

   $newheight_thm = 50;
       $newwidth_thm = 80;

       $tmp=imagecreatetruecolor($newwidth,$newheight);
       $tmp_thm=imagecreatetruecolor($newwidth_thm, $newheight_thm);
       if($size[2] == IMAGETYPE_GIF)

       {

        $src = imagecreatefromgif($tmp_name);

        imagecopyresampled($tmp,$src, 0,0,0,0, $newwidth, $newheight, $width, $height);
        imagecopyresampled($tmp_thm, $src, 0,0,0,0, $newwidth_thm, $newheight_thm, $width, $height);
        imagegif($tmp,$filename,100);
        imagegif($tmp_thm,$thm_filename,100);

       }

       elseif($size[2] == IMAGETYPE_JPEG)

       {

        $src = imagecreatefromjpeg($tmp_name);

        imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
        imagecopyresampled($tmp_thm, $src, 0,0,0,0, $newwidth_thm, $newheight_thm, $width, $height);
        imagejpeg($tmp,$filename,100);
        imagejpeg($tmp_thm,$thm_filename,100);
       }

       elseif($size[2] == IMAGETYPE_PNG)

       {

        $src = imagecreatefrompng($tmp_name);

        imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
        imagecopyresampled($tmp_thm, $src, 0,0,0,0, $newwidth_thm, $newheight_thm, $width, $height);
        imagepng($tmp,$filename,9);
        imagepng($tmp_thm,$thm_filename,9);

       }
       imagedestroy($src);

       imagedestroy($tmp);
</code></pre>
