當我在網頁中調用我的圖像大小調整功能,它運行平穩,調整圖片的大小,但是當我包括在我的索引頁,並從的index.php然後頭不叫發送併產生如此長的文字圖像頭不會從OOP傳遞到index.php
=>GIF87aªç–ƒx‡dWtaZffeCA<ÕƶCBBŠVNfXT;BC§‡w²¤™wxw¹†g‡˜–êÆ©C;:x‡‡ˆˆ…
等等。請解決我的問題,否則我會直接在index.php中創建這個函數?
下面
class img{
function resize()
{
// File and new size
$filename = 'upload/845.gif';
$percent = 0.5;
// Content type
ob_start();
echo header("Content-Type: image/gif");
ob_end_clean();
// Get new sizes
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;
// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromgif($filename);
// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// Output
@imagegif($thumb);
imagedestroy($thumb);
}
}
這是我function.php網頁代碼這是我的index.php代碼如下
<html>
<body>
<?php
include("function.php");
$img_resize=new img;
$img_resize->resize();
?>
</body>
</html>
這是什麼都與OOP呢? –
它生成縮略圖.... – waqaxi
是否有其他內容您打算在同一時間顯示,或者你只是想顯示圖像? – ray