resource imagescale ( resource $image , int $new_width [, int $new_height = -1 [, int $mode = IMG_BILINEAR_FIXED ]] )
imagescale() scales an image using the given interpolation algorithm.

参数

image
由图象创建函数(例如imagecreatetruecolor())返回的图象资源。

new_width
寬度縮放圖像

new_height
高度縮放圖像。如果省略或負,寬高比將被保留。

Caution
如果使用PHP 5.5.18或你應該總是提供高度更早版本,或者PHP 5.6.2或更早版本,縱橫比的計算是不正確的。

mode
一IMG_NEAREST_NEIGHBOUR, IMG_BILINEAR_FIXED, IMG_BICUBIC, IMG_BICUBIC_FIXED或其他任何東西(將使用兩個通)。

 

使用imagescale()從PHP 5.5.0,簡化您的大小調整/縮放圖像的過程。
<?php

$imgresource = imagecreatefromjpeg("test.jpg"); //原圖600*450
$imgresource = imagescale($imgresource, 300, 225); //縮圖

header("Content-Type: image/jpeg");
// Output
imagejpeg($imgresource, null, 100);

?>

 

arrow
arrow
    全站熱搜

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