為了使網(wǎng)站看起來(lái)美觀,不少的朋友會(huì)選擇圖文搭配建站,那么關(guān)于圖片大小的裁剪成為不可或缺的功能,文章總結(jié)了php圖片裁剪實(shí)現(xiàn)方法,希望對(duì)您有所幫助!
核心技術(shù):imagecopyresampled(dst_image, src_image, dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h)。
實(shí)現(xiàn)代碼:
<?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);
新聞熱點(diǎn)
疑難解答
圖片精選