When i am calling my image resize function within the page it runs smoothly and resize my image but when i include it in my index page and call it from index.php then header not sends and it generate a long text like this
=>GIF87aªç–ƒx‡dWtaZffeCA<ÕÆ¶CBBŠVNfXT;BC§‡w²¤™wxw¹†g‡˜–êÆ©C;:x‡‡ˆˆ…
and so on. Please resolve my issue or i will create this function directly in index.php?
This my function.php page code below
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);
}
}
This is my index.php code below
<html>
<body>
<?php
include("function.php");
$img_resize=new img;
$img_resize->resize();
?>
</body>
</html>
You need to create a separate file to output the image and then load it in an
<img>tag.That’s if you’re trying to include the image in an HTML file. If you’re just trying to output the image, as others have hinted, then you don’t need any HTML at all you just want to output the image.