Code:
$imx = imagesx($im);
$imy = imagesy($im);
$w = imagesx($watermark);
$h = imagesy($watermark);
$y = $imy - $h;
$x = $imx - $w;
imagecopy($im, $watermark, $x, $y, 0, 0, $w, $h);
from here, i think you get the concept. you use the the size of the watermark, and then subtract/add accordingly from the min/max size of the image being watermarked. (from left, x is 0, from right, x is imagesx())
Made correction on $h=...