I got this code from some where and dont remember where but I cant get it to work. I get a Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING on line 8
Also to save another thread can this be made to resize any picture insted of just jpgs. also insted of setting the size to 600 x 442 can that be 600 x what ever is Proportion. I know this is a lot of questions, but Im new and trying to save some threading here.
<?php
// Max height and width
$max_width = 600;
$max_height = 442;
// Path to your jpeg
$upfile '/myhome/yappys/public_html/uploads/';
Header("Content-type: image/jpg");
$size = GetImageSize($upfile); // Read the size
$width = $size[0];
$height = $size[1];
// Proportionally resize the image to the
// max sizes specified above
$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;
if( ($width <= $max_width) && ($height <= $max_height) )
{
$tn_width = $width;
$tn_height = $height;
}
elseif (($x_ratio * $height) < $max_height)
{
$tn_height = ceil($x_ratio * $height);
$tn_width = $max_width;
}
else
{
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}
// Increase memory limit to support larger files
ini_set('memory_limit', '32M');
// Create the new image!
$src = ImageCreateFromJpeg($upfile);
$dst = ImageCreateTrueColor($tn_width, $tn_height);
ImageCopyResized($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height);
ImageJpeg($dst);
// Destroy the images
ImageDestroy($src);
ImageDestroy($dst);
?>