title: Resize and Watermark Image PHP
body: <p>Could someone help with the following PHP code, please.</p>
  
  <p>I am wanting to resize and add watermark to the uploaded image - here is the code...</p>
  
  <pre><code>$image = $_FILES['file']['tmp_name'];
  $image_name = $_FILES['file']['name'];
  
  $image_size = getimagesize($image);
  $image_width = $image_size[0];
  $image_height = $image_size[1];
  
  // Resizes image to roughly 150px by 100px
  $new_size_small = ($image_width + $image_height)/($image_width * ($image_height / 75));
  
  $new_width_small = $image_width * $new_size_small;
  $new_height_small = $image_height * $new_size_small;
  
  $location_small = "Product Images/Small Images/{$image_name}";
  
  $new_image_small = imagecreatetruecolor($new_width_small, $new_height_small);
  
  $source_image = imagecreatefromjpeg($image);    
  
  imagecopyresampled($new_image_small, $source_image, 0, 0, 0, 0, $new_width_small, $new_height_small, $image_width, $image_height);   
  
  $location_watermark = "Graphics/coming_soon.png";
  
  $watermark = imagecreatefrompng($location_watermark);
  
  $watermark_width = imagesx($watermark);
  $watermark_height = imagesy($watermark);
  
  $image_watermark = imagecreatetruecolor($watermark_width, $watermark_height);
  
  imagecopymerge($image_watermark, $source_image, $new_width_small, $new_height_small, 0, 0, $watermark_width, $watermark_height, 100);
  
  imagejpeg($image_watermark, $location_small, 100);
  </code></pre>
  
  <p>Once the image is uploaded, it should resize to roughly 150px by 100px and then save into the following folder on the server (Product Images/Small Images/) </p>
  
  <p>I am able to resize the image successfully but once I apply the watermark code it stops working!            </p>