echo "<img src='resize-image.php?image=".$filename."'>";
resize-image.php:
<?php
//destroy image first as the img tag that calls it is in a loop
ImageDestroy($src);
ImageDestroy($dst);
if (!$max_width)
$max_width = 150;
if (!$max_height)
$max_height = 100;
$size = GetImageSize($image)or die("Could not get image size");
$width = $size[0];
$height = $size[1];
$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;
if (($width <= $max_width) && ($height <= $max_height))
{
$tn_width = $width;
$tn_height = $height;
}
else if (($x_ratio $height) < $max_height)
{
$tn_width = $max_width;
$tn_height = ceil($x_ratio height);
echo "<br>tn_height: ".$tn_height;
}
else
{
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}
$src = ImageCreateFromJpeg($image)or die("Could not create from Jpeg");
$dst = ImageCreateTrueColor($tn_width, $tn_height)or die("Could not create new image");
ImageCopyResized($dst, $src, 0,0,0,0, $tn_width, $tn_height, $width, $height)or die("Could not copy resized");
header('Content-type: image/jpg');
imagejpeg($dst, null, 75);
?>
However no image is returned. In firefox nothing and in IE just the red cross box. That box shows the image src as resize-image.php?
I've tried moving teh header around but it doesn't work at the top of resize-image.php or at the top of the page that calls it.
Any ideas?