Dear all,
i am using php 4.3.10 and i am having problems using an image resizing function in a file that i have name resize_image.php that i call like this anytime i want to resize a photo: <?php echo "<img src=\"photos\/resize_image.php?image=".$ppt_code.".JPEG\">";
?>
I have GD library installed but the resized image does not show up. What do you think is the cause?
Note that everything works fine on another machine using php 4.2.0 . Below is the code in resize_image.php:
<?php
//if (!max_width)
(double)$max_width = 150;
//if (!max_height)
(double)$max_height = 100;
$size = GetImageSize("$image");
(double)$width = $size[0];
(double)$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_height = ceil($x_ratio$height);
$tn_width = $max_width;
}
else {
(double)$tn_width = ceil($y_ratio*$width);
$tn_height = $max_height;
//echo $tn_width;
//echo $tn_height;
//exit;
}
$src = ImageCreateFromJPEG("$image");
//echo $tn_width;
// echo $tn_height;
//exit;
$dst = ImageCreate($tn_width, $tn_height);
ImageCopyResized($dst, $src, 0,0,0,0, $tn_width, $tn_height, $width, $height);
error_reporting(0);
header("Content-type: image/jpeg");
ImageJPEG($dst, null, -1);
ImageDestroy($src);
ImageDestroy($dst);
?>
Thank you in advance.