I am writing a script that displays the user profile with a picture. The picture must be resized at run time to a certain size, to do so I using the following script.
// Start the session
session_start();
// The file
$filename = './profile/'.$_SESSION['photo'].'';
// Set a maximum height and width
$width = 200;
$height = 200;
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);
$ratio_orig = $width_orig/$height_orig;
if ($width/$height > $ratio_orig) {
$width = $height*$ratio_orig;
} else {
$height = $width/$ratio_orig;
}
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Output put in selected file
This script works soley but when implemented into any script it returns characters along these lines - -d™¤çyB\·Ìç2”UÚÕ$Ö‰µ¢išÓDoÆ 8Â:i¬Sén·ü;¾†³ê
Can anyone guide me to what would cause this? I am running php5 and the gd library is installed. I can't seem to understand why this is happening.
Thanks -