|
 |
|
สอบถามเรื่อง Resize รูปภาพที่เป็นสกุล png แล้วทำไมแบล็กกราวถึงเป็นสีดำครับ |
|
 |
|
|
 |
 |
|
สอบถามเรื่อง Resize รูปภาพที่เป็นสกุล png แล้วทำไมแบล็กกราวถึงเป็นสีดำครับ มีวิธีที่ทำให้เป็น transparent ครับ
Code (PHP)
<?php
if($fileupload){
$array_last=explode(".",$fileupload_name);
$c=count($array_last)-1;
$lastname=strtolower($array_last[$c]);
if($lastname=="gif" or $lastname=="jpg" or $lastname=="jpeg" or $lastname=="png") {
$sql2="SELECT MAX(id_prd) FROM tb_product";
$result2=mysql_db_query($dbname,$sql2);
$row=mysql_fetch_row($result2);
$photoname=$row[0].".".$lastname;
copy($fileupload,$dirprd.$photoname);
// ตรวจสอบนานสกุลไฟล์
if($lastname=="jpg" or $lastname=="jpeg") {
$ori_img = imagecreatefromjpeg($fileupload);
} else if($lastname=="png") {
$ori_img = imagecreatefrompng($fileupload);
} else if($lastname=="gif") {
$ori_img = imagecreatefromgif($fileupload);
}
// หาและสร้างขนาดไฟล์
$ori_size = getimagesize($fileupload);
$ori_w = $ori_size[0];
$ori_h = $ori_size[1];
// ตรวจสอบความกว้างความยาว
if ($ori_w>$ori_h) {
$new_w = 150;
$new_h = round(($new_w/$ori_w) * $ori_h);
} else {
$new_h =150;
$new_w = round(($new_h/$ori_h) * $ori_w);
}
$new_img = imagecreatetruecolor($new_w,$new_h);
imagecopyresized($new_img,$ori_img,0,0,0,0,$new_w,$new_h,$ori_w,$ori_h);
if ($lastname=="jpg" or $lastname=="jpeg") {
imagejpeg($new_img,"../product_small/$photoname");
} else if($lastname=="png") {
imagepng($new_img,"../product_small/$photoname");
} else if($lastname=="gif") {
imagegif($new_img,"../product_small/$photoname");
}
imagedestroy($ori_img);
imagedestroy($new_img);
$sql3="UPDATE tb_product SET img_prd='$photoname' WHERE id_prd='$row[0]' ";
$result3=mysql_db_query($dbname,$sql3);
}
unlink($fileupload);
}
?>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-08-20 22:54:08 |
By :
TonNgiew |
View :
1787 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เพิ่ม ส่วนลงไป อาจ ช่วยได้นะครับ...
Code (PHP)
<?php
$get_extension=explode(".",$_FILES[$fsname]["name"]);
if($get_extension[1]=="png")
$images_orig =imagecreatefrompng($images);
?>
|
 |
 |
 |
 |
Date :
2009-08-21 08:08:02 |
By :
nilas |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|