This seems wrong to me. You can't output an HTTP header once you've already started outputting HTML text.
In your code, you have:
Quote:
quote:Originally posted by cli
Code:
<html>
<head>
</head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>
<?php
$mydir = "uploaded_image_visual";
$mynameimage = "sezioni_capelli.jpg";
$myimage = $mydir."/".$mynameimage ;
$mainImage = imagecreatefromjpeg($myimage);
$mainWidth = imagesx($mainImage);
$mainHeight = imagesy($mainImage);
$thumbWidth = intval($mainWidth / 4);
$thumbHeight = intval($mainHeight / 4);
$myThumbnail = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresampled($myThumbnail, $mainImage, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $mainWidth, $mainHeight);
header("Content-type: image/jpeg");
imagejpeg($myThumbnail);
imagedestroy($myThumbnail);
imagedestroy($mainImage);
?>
</td>
</tr>
</table>
</body>
</html>
|
If you're going to output an image, you need to have an <img> tag with a filename/path to the image file. Now, this filename can be a PHP file, as long as the PHP script outputs the proper header for the image Content-type and spits out the binary image data.
If you already have the image files on your machine, perhaps you should write a generic resizer script that accepts the filename as a GET parameter and resizes whatever filename you pass in.
Make sense?