chadconger
07-25-2006, 02:06 AM
My goal is to resize a picture that has been uploaded so I researched how to do that and found my code at http://us2.php.net/manual/en/function.imagecopyresampled.php it is example two. I uploaded a picture named test.jpg to the same directory as the page and I get this error
Warning: Cannot modify header information - headers already sent by (output started at /home/istockfi/public_html/spurtstudios/test.php:2) in /home/istockfi/public_html/spurtstudios/test.php on line 12
followed by a lot of charaters that make no sense to me. You can view the acual page at http://www.spurtstudios.com/test.php
You can view my GD info at http://www.spurtstudios.com/gd.php
Can anyone point me in the right direction?
I have tried several other scripts like this one with no luck so I think it may be a a problem with my host but I don't know what I should do or what to ask them to do.
Here is my code
<?php
// The file
$filename = 'test.jpg';
// Set a maximum height and width
$width = 200;
$height = 200;
// Content type
header('Content-type: image/jpeg');
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);
if ($width && ($width_orig < $height_orig)) {
$width = ($height / $height_orig) * $width_orig;
} else {
$height = ($width / $width_orig) * $height_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
imagejpeg($image_p, null, 100);
?>
Warning: Cannot modify header information - headers already sent by (output started at /home/istockfi/public_html/spurtstudios/test.php:2) in /home/istockfi/public_html/spurtstudios/test.php on line 12
followed by a lot of charaters that make no sense to me. You can view the acual page at http://www.spurtstudios.com/test.php
You can view my GD info at http://www.spurtstudios.com/gd.php
Can anyone point me in the right direction?
I have tried several other scripts like this one with no luck so I think it may be a a problem with my host but I don't know what I should do or what to ask them to do.
Here is my code
<?php
// The file
$filename = 'test.jpg';
// Set a maximum height and width
$width = 200;
$height = 200;
// Content type
header('Content-type: image/jpeg');
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);
if ($width && ($width_orig < $height_orig)) {
$width = ($height / $height_orig) * $width_orig;
} else {
$height = ($width / $width_orig) * $height_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
imagejpeg($image_p, null, 100);
?>