/** * 生成指定尺寸的图片. * * @access public * @param integer $w 目标宽度. * @param integer $h 目标高度. * @param string $src 图片位置. */ public function resizeImg($w, $h, $src) { try { $image = new \Api\Lib\Image\Image(); $image->open($src)->thumb($w, $h, \Api\Lib\Image\Image::IMG_THUMB_SCALE)->output(); } catch (\Exception $e) { echo $e->getMessage(); } }
<?php /** * Created by PhpStorm. * User: kylin * Date: 16-4-15 * Time: 下午4:46 */ $w = isset($_GET['w']) ? (int) $_GET['w'] : '514'; $h = isset($_GET['w']) ? (int) $_GET['h'] : '205'; $src = isset($_GET['src']) ? $_GET['src'] : ''; include './Application/Api/Lib/Image/IImageDriver.class.php'; include './Application/Api/Lib/Image/Image.class.php'; include './Application/Api/Lib/Image/driver/Gif.class.php'; include './Application/Api/Lib/Image/driver/Gd.class.php'; try { $image = new \Api\Lib\Image\Image(); $image->open($src)->thumb($w, $h, \Api\Lib\Image\Image::IMG_THUMB_CENTER)->output(); } catch (\Exception $e) { echo $e->getMessage(); }