title: PHP watermark proportional resizing
body: <p>:)
  I'm actually working on an online photo book and to complete it, i need to create a watermarking script.
  But it definitely doesn't works! I REALLY do not understand why.
  I need to resize proportionally the watermark; I have made all the ratio calculations, everything seems clear, but nothing works, help me please!</p>
  
  <p>Here is the code:</p>
  
  <pre><code>&lt;?php
  // Load the stamp and the photo to apply the watermark to
  $stamp = imagecreatefrompng('stamp.png');
  $im = imagecreatefromjpeg('531a1251532b0.jpg');
  
  // get the height/width of the stamp image
  $sx = imagesx($stamp);
  $sy = imagesy($stamp);
  $syimg = imagesy($im);
  
  //percentage of the size(4%)
  $percent = 4/$syimg;
  $sx2 = $sx * $percent;
  $sy2 = $sy * $percent;
  
  $posx = (imagesx($im) / 2) - $sx2;
  $posy = (imagesy($im) / 2) - $sy2;
  //checking (everything is ok!)
  //echo "per: ". $percent;
  //echo "&lt;br&gt;\n sx: ". $sx2;
  //echo "&lt;br&gt;\n posx: ". $posx;
  //echo "&lt;br&gt;\n sy: ". $sy2;
  //echo "&lt;br&gt;\n posy: ". $posy;
  //echo "&lt;br&gt;\n syimg : ". $syimg;
  //echo "&lt;br&gt;\n sximg : ". imagesx($im);
  
  // Copy the stamp image onto the photo 
  // width to calculate positioning of the stamp.
  imagecopy($im, $stamp, round($posx), round($posy), 0, 0, round($sx2), round($sy2));
  
  // Output and free memory
  header('Content-type: image/jpg');
  imagepng($im);
  imagedestroy($im);
  ?&gt;
  </code></pre>
  
  <p>Thanks for the future replies!</p>