|
 |
|
PHP GD2 ทำสีเพี้ยน function imagecopyresized() ครับมันจะแสดงรูปออกมาประมาณ ขาวดำครับ |
|
 |
|
|
 |
 |
|
ลองแบบนี้มั๊ย
<img src="resize.php?file=image01.jpg" alt="">
file: resize.php
<?php
$file = $_GET['file'];
$max_x = 120;
$max_y = 120;
$size = GetImageSize($file);
$x = $size[0];
$y = $size[1];
$x_ratio = $max_x / $x;
$y_ratio = $max_y/$y;
if(($x <= $max_x) && ($y <= $max_y)){
$new_x = $x;
}
else if(($x_ratio * $y) < $max_y){
$new_x = $max_x;
$new_y = ceil($x_ratio * $y);
}
else{
$new_x = ceil($y_ratio * $x);
$new_y = $max_y;
}
$src = ImageCreateFromJpeg($file);
// $dst = ImageCreate($new_x,$new_y);
$dst = Imagecreatetruecolor ($new_x,$new_y);
ImageCopyResized($dst,$src,0,0,0,0,$new_x,$new_y,$x,$y);
header("Content-type: image/jpeg");
ImageJpeg($dst,null,-1);
ImageDestroy($src);
ImageDestroy($dst);
?>
|
 |
 |
 |
 |
Date :
2009-07-03 18:15:35 |
By :
sirikulo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับเดี๋ยวลองดูก่อนนะครับ
|
 |
 |
 |
 |
Date :
2009-07-03 18:49:49 |
By :
israel |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
งืมมมมมมม
มันเป็นอย่างงี้งะ

ปกติมันจะมีสีนะ
|
 |
 |
 |
 |
Date :
2009-07-03 19:27:55 |
By :
israel |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
งืมๆ ได้และ
มันต้อง
$dst = Imagecreatetruecolor ($new_x,$new_y);
 
ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2009-07-03 19:33:53 |
By :
israel |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|