イメージリサイズ機能をページ内で呼び出すと、スムーズに実行され、イメージのサイズが変更されますが、インデックスページにインクルードして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ページのコードこれは、あなたがbody
タグを入力した後にあなたは、ヘッダー情報を送信している
<html>
<body>
<?php
include("function.php");
$img_resize=new img;
$img_resize->resize();
?>
</body>
</html>
のようにしてみてください? –
それはサムネイル画像を生成します.... – waqaxi
同時に表示する他のコンテンツはありますか、それとも単に画像だけを表示したいですか? – ray