我使用此代码在图像上添加水印。问题是,当我更改$sx,$sy时,它会剪切水印,而不会更改大小。
我该怎么办?
守则:
$sx = imagesx($stamp);
$sy = imagesy($stamp);
$des_width = imagesx($im);
$des_height = imagesy($im);
$xpos = $des_width - $sx - $marge_right;
$ypos = $des_height - $sy - $marge_bottom;
$trans_background = imagecolorallocatealpha($im, 0, 0, 0, 127);
$dest_image = imagecreatetruecolor($des_width, $des_height);
imagesavealpha($dest_image, true);
$trans_background = imagecolorallocatealpha($dest_image, 0, 0, 0, 127);
imagefill($dest_image, 0, 0, $trans_background);
imagecopy($dest_image, $im, 0, 0, 0, 0, $des_width, $des_height);
imagecopy($dest_image, $stamp, $xpos, $ypos, 0, 0, $sx, $sy);
if(pathinfo($file, PATHINFO_EXTENSION) == 'png'){
imagepng($dest_image, $file);
} else {
imagejpeg($dest_image, $file, 99);
}
imagedestroy($stamp);
imagedestroy($im);
imagedestroy($dest_image);
暂无答案!
目前还没有任何答案,快来回答吧!