/**
     * 处理图片尺寸【等比例缩小或放大】
     * @param $filePath【进行处理图片本地地址】
     * @param $saveImage【处理后保存地址】
     * @param $maxWidth【最大宽度】
     * @param $maxHeight【最大高度】
     * @param $minWith【最小宽度】
     * @param $minHeight【最小高度】
     */
    function resizeImage($filePath, $saveImage, $maxWidth, $maxHeight, $minWith, $minHeight)
    {
        //获取图片基础信息
        $tmpImageSize = getimagesize($filePath);
        $originalImageWidth = $tmpImageSize[0];    //宽度
        $originalImageHeight = $tmpImageSize[1];   //长度
        $originalImageType = $tmpImageSize[2];     //类型
        //保存图片的宽度跟高度
        $targetWidth = $tmpImageSize[0];
        $targetHeight = $tmpImageSize[1];
        //计算图片将要保存的尺寸
        if ($originalImageWidth > $maxWidth) {           //图片宽度超过最大限度
            $targetWidth = $maxWidth;
            $targetHeight = $originalImageHeight * ($maxWidth / $originalImageWidth);
        }
        if ($originalImageWidth < $minWith) {            //图片宽带小于最小限度
            $targetWidth = $minWith;
            $targetHeight = $originalImageHeight * ($minWith / $originalImageWidth);
        }
        if ($targetHeight > $maxHeight) {                //图片高度超过最大限度
            $targetWidth = $targetWidth * ($maxHeight / $targetHeight);
            $targetHeight = $maxHeight;
        }
        if ($targetHeight < $minHeight) {               //图片高度小于最小限度
            $targetWidth = $targetWidth * ($minHeight / $targetHeight);
            $targetHeight = $minHeight;
        }
        //最后检验宽度跟高度是否符合【兜底】
        if ($targetWidth < $minWith) {
            $targetWidth = $minWith;
        }
        if ($targetWidth > $maxWidth) {
            $targetWidth = $maxWidth;
        }
        if ($targetHeight < $minHeight) {
            $targetHeight = $minHeight;
        }
        if ($targetHeight > $maxHeight) {
            $targetHeight = $maxHeight;
        }
        //四舍五入
        $targetWidth = ceil($targetWidth);
        $targetHeight = ceil($targetHeight);
        //判断图片格式进行处理
        if ($originalImageType == 1) {
            $temPic = imagecreatefromgif($filePath);
        } else if ($originalImageType == 2) {
            $temPic = imagecreatefromjpeg($filePath);
        } else if ($originalImageType == 3) {
            $temPic = imagecreatefrompng($filePath);
        } else {
            exit();
        }
        //保存图片
        $thPic = imagecreatetruecolor($targetWidth, $targetHeight);
        // 调整默认颜色
        $color = imagecolorallocate($thPic, 255, 255, 255);
        imagefill($thPic, 0, 0, $color);
        //裁剪
        imagecopyresampled($thPic, $temPic, 0, 0, 0, 0, $targetWidth, $targetHeight,
            $originalImageWidth, $originalImageHeight);
        //保存图片
        imagejpeg($thPic, $saveImage);
    }
//调用
$this->resizeImage(public_path().$url,public_path().$url,1000,1000,400,400);