title: Black Background Issue with GD Library while adding watermark
body: <p>I am facing issues with adding watermark to images using GD Library, the same code works fine on my local Ubuntu Server which has PHP Version 5.4.6-1ubuntu1.4 with GD version 2.0 but produces a black background to the image after the ending of the watermark image, my website is hosted on hostgator and i have also upgraded the server to use PHP Version 5.4.20 with GD Version bundled (2.1.0 compatible) but still the same issue. </p>
  
  <p>The following is the code that works for the local server but produces the black image on the server</p>
  
  <pre><code>imagecreatefromjpeg($img);
  
  $targetImage = imagecreatetruecolor($width, $height);
  
  $watermark = imagecreatefrompng($watermark_src);
  imagealphablending($watermark, true);
  //imagesavealpha($watermark, true);
  $black = imagecolorallocate($watermark, 0, 0, 0); 
  
  imagecolortransparent($watermark, $black);
  
  imagecopy($img, $watermark, $final_x, $final_y, 0, 0, $W, $H);
  
  imagedestroy($img);
  
  imagejpeg($img);
  </code></pre>
  
  <p>Also i have tried making many changes to the code for the server to work like removing the code for the black variable adding imagesaveaplha etc but still no luck.</p>
  
  <p>The variables names may differ for the functions because the process uses multiple function to accomplish the task the but the sequence is the same the i have written above. Also the code works fine if i run it separately but when i am using it with my joomla component it has the black background issue</p>