圈中裁剪图像(php)
发布时间:2020-12-13 13:33:55 所属栏目:PHP教程 来源:网络整理
导读:以下代码适用于我的笔记本电脑,但在远程服务器上不起作用: ?phperror_reporting(E_ALL);ini_set('display_errors','1');$filename = "../../content/".base64_decode($_GET["file"]);$ext = pathinfo($filename,PATHINFO_EXTENSION);if ($ext=="jpg" || $ex
以下代码适用于我的笔记本电脑,但在远程服务器上不起作用:
<?php error_reporting(E_ALL); ini_set('display_errors','1'); $filename = "../../content/".base64_decode($_GET["file"]); $ext = pathinfo($filename,PATHINFO_EXTENSION); if ($ext=="jpg" || $ext=="jpeg") { $image_s = imagecreatefromjpeg($filename); } else if ($ext=="png") { $image_s = imagecreatefrompng($filename); } $width = imagesx($image_s); $height = imagesy($image_s); $newwidth = 285; $newheight = 232; $image = imagecreatetruecolor($newwidth,$newheight); imagealphablending($image,true); imagecopyresampled($image,$image_s,$newwidth,$newheight,$width,$height); // create masking $mask = imagecreatetruecolor($width,$height); $mask = imagecreatetruecolor($newwidth,$newheight); $transparent = imagecolorallocate($mask,255,0); imagecolortransparent($mask,$transparent); imagefilledellipse($mask,$newwidth/2,$newheight/2,$transparent); $red = imagecolorallocate($mask,0); imagecopy($image,$mask,$newheight); imagecolortransparent($image,$red); imagefill($image,$red); // output and free memory header('Content-type: image/png'); imagepng($image); imagedestroy($image); imagedestroy($mask); ?> 它在我的笔记本电脑上显示以下图像: 这就是它在远程服务器上的显示方式: 你怎么看?有什么问题?
改变了行:
imagecopy($image,$newheight); 至: imagecopymerge($image,100); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |