代码如下 | 复制代码 |
header("Content-type:image/png"); set_time_limit(0);//设置PHP超时时间 $url = $_GET['url']; $url = "http://vcer.baidu.com/verify"; $imginfo = GetImageSize ( $url ); $imgw = $imginfo [0]; $imgh = $imginfo [1]; $bg = imagecreatetruecolor($imgw,$imgh); $image = imagecreatefromjpeg($url); imagecolorallocate($image,255,255,255); imagecopy($bg,$image,0,0, 0,0,$imgw,$imgh); imagedestroy($image); ImagePng($bg); |
获取远程验证码到本地
代码如下 | 复制代码 |
header("Content-type:image/png"); set_time_limit(0);//设置PHP超时时间 $url = $_GET['url']; $url = "http://vcer.baidu.com/verify"; if(empty($url)){ echo "没有图片"; die; } $imginfo = GetImageSize ( $url ); $type = exif_imagetype($url); $imgw = $imginfo [0]; $imgh = $imginfo [1]; $bg = imagecreatetruecolor($imgw,$imgh); if($type==IMAGETYPE_GIF){ $image = imagecreatefromgif($url); }elseif($type==IMAGETYPE_JPEG){ $image = imagecreatefromjpeg($url); }elseif($type==IMAGETYPE_PNG){ $image = imagecreatefrompng($url); } imagecolorallocate($image,255,255,255); imagecopy($bg,$image,0,0, 0,0,$imgw,$imgh); imagedestroy($image); ImagePng($bg); |
时间: 2024-09-15 04:34:58