php基础练习--图片裁剪

php基础练习--图片裁剪:

<?php 

    /**

    * cutimage

    *

    */



    $filename = "./images/gg.jpg";

    $src_image = imagecreatefromjpeg($filename);



    $w = 200;

    $h = 200;

    $src_x = 250;

    $src_y = 250;

    $dst_image = imagecreatetruecolor($w, $h);



    imagecopyresampled($dst_image, $src_image, 0, 0, $src_x, $src_y, $w, $h, $w, $h);



    header("content-type:image/jpeg");

    imagejpeg($dst_image);



    imagedestroy($dst_image);
View Code

技术点:imagecopyresampled(dst_image, src_image, dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h)。

你可能感兴趣的:(php基础)