Водяной знак на изображение

$big = imagecreatefromjpeg($dir.'/'.$item->file);
$wm = imagecreatefrompng(PATH_ROOT.'/img/wm.png');
$wmx = imagesx($wm);
$wmy = imagesy($wm);
$out = imageCreateTrueColor(SNAP_BIG_W, SNAP_BIG_H);
imagecopymerge($out, $big, 0, 0, 0, 0, SNAP_BIG_W, SNAP_BIG_H, 100);
imagecopy($out, $wm, (SNAP_BIG_W-$wmx)/2, SNAP_BIG_H-$wmy-16, 0, 0, $wmx, $wmy);
//imagecopymerge($out, $wm, (SNAP_BIG_W-$wmx)/2, SNAP_BIG_H-$wmy-16, 0, 0, $wmx, $wmy, 100);
unlink($dir.'/'.$item->file);
imagejpeg($out, $dir.'/'.$item->file);
imagedestroy($out);
imagedestroy($wm);
imagedestroy($big);