PHP按坐标裁图

 /**
     * 按坐标裁图
     * 参数:起始坐标,裁剪长宽,图片
     * 坐标($h,$w)
     * 长宽($height,$weight)
     */
    public function actionCutByPoint()
    {
        // $data = $_POST;
        $data = $_GET;

        $filename = dirname(dirname(dirname(dirname(__FILE__)))).'\web\upload_pic\test114.png';
        $source = imagecreatefrompng($filename);

        list($PNGWidth, $PNGHeight) = getimagesize($filename);
        $thumb = ImageCreateTrueColor( $data['weight'],$data['height']);
        imagecopyresized( $thumb, $source, 0, 0, $data['w'], $data['h'], $data['weight'], $data['height'],  $data['weight'], $data['height']);
        imagejpeg( $thumb , "./upload_pic/Cut/{$data['w']}-{$data['h']}.jpg" ,100);

    }

 

posted @ 2018-07-16 18:08  LiuLiwei  阅读(278)  评论(0)    收藏  举报