-1
我想uplod全寬和全高圖像,這是腳本 ,但不知道哪裏的錯誤?如何圖像使用imagecreatetruecolor函數調整大小
我想要上傳全寬和高(原寬度和高度)圖片.. 檢查下面的代碼一次。此代碼返回600 400圖像,但我想要原始寬度和高度圖像。
<?php
function create_image($file) {
// Content type
header('Content-Type: image/jpeg');
header('Content-Type: text/html');
// Get new sizes
list($width, $height) = getimagesize($file['tmp_name']);
// Load
$thumb = imagecreatetruecolor(600, 400);
$wmext = explode(".",$file['name']);
$wmext = end($wmext);
switch ($wmext) {
case 'jpg' :
$source = imagecreatefromjpeg($file['tmp_name']);
break;
case 'png' :
$source = imagecreatefrompng($file['tmp_name']);
break;
case 'gif' :
$source = imagecreatefromgif($file['tmp_name']);
break;
default :
// progress_log("Resize error for image : $file");
}
// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, 600, 400, $width, $height);
$final_file = "Thumb_".time()."_".$file['name'];
imagejpeg($thumb,"uploads/".$final_file);
//echo '<img src="uploads/'.$final_file.'">';
imagedestroy($thumb);
return $final_file;
}
?>
我不明白,如果你想要原始的寬度和高度,你爲什麼要調整大小?你爲什麼發送矛盾的標題?或者所有頭文件? – jeroen
這個腳本是從谷歌,我試圖刪除調整大小的代碼..你可以刪除調整大小代碼的工作? –
你應該試試php手冊。 – jeroen