|
|
|
php จะทำการ resize ย่อรูปให้เล็กตามขนาดที่ต้องการทำอย่างไรครับ บอกที |
|
|
|
|
|
|
|
Code (PHP)
<?
$images = "mygirl.jpg";
$new_images = "MyResize/mygirl.jpg";
$width=200; //*** Fix Width & Heigh (Autu caculate) ***//
$size=GetimageSize($images);
$height=round($width*$size[1]/$size[0]);
$images_orig = ImageCreateFromJPEG($images);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
ImageJPEG($images_fin,$new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
?>
<b>Original Size</b><br>
<img src="<?=$images;?>">
<hr>
<b>New Resize</b><br>
<img src="<?=$new_images;?>">
Ref : PHP Resize image
|
|
|
|
|
Date :
2009-04-25 07:23:51 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|