-
-
-
- Get Image From Web
-
-
-
-
-
2、文件 getimage.php
- // set up variable
- $url = $_REQUEST['url'];
- // echo "
8 ".$url."
"; - $ext = substr($url, strrpos($url, '.')+1);
- // echo '
9 '.$ext.'
'; - $filename = substr($url, strrpos($url, '/')+1, -(strlen($ext) + 1));
- // echo '
10 '.$filename.'
'; - if ($ext == 'jpg') {
- $im = imagecreatefromjpeg($url);
- if ($im) {
- // echo '
created image handle
'; - $width = imagesx($im);
- $height = imagesy($im);
- $x = $width/2;
- $y = $height/2;
- $dst = imagecreatetruecolor($x, $y);
- imagecopyresampled($dst, $im, 0, 0, 0, 0, $x, $y, $width, $height);
- header("Content-Type:image/jpeg");
- // imagejpeg($dst, 'https://www.gxlcms.com/imgdst.jpg');
- imagejpeg($dst);
- imagedestroy($dst);
- imagedestroy($im);
- // echo '';
- }
- }
- ?>
说明:
将收到的url中的网页转换为图片,缩放后再显示到浏览器。 |