int imagecopyresized ( resource dst_image, resource src_image, int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h )

dst_image -- 輸出目標檔案
src_image -- 來源檔案
dst_x -- 目標檔案開始點的 x 座標
dst_y -- 目標檔案開始點的 y 座標
src_x -- 來源檔案開始點的 x 座標
src_y -- 來源檔案開始點的 y 座標
dst_w -- 目標檔案的長度
dst_h -- 目標檔案的高度
src_w -- 來源檔案的長度
src_h -- 來源檔案的高度

這個例子會以一半的尺寸顯示圖片

<?php
// File and new size
$filename = 'test.jpg';
$percent = 0.5;

// Content type
header('Content-Type: image/jpeg');

// Get new sizes
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;

// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);

// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

// Output
imagejpeg($thumb);
?>

arrow
arrow
    全站熱搜

    stockwfj3 發表在 痞客邦 留言(0) 人氣()