Hi all,
I was looking at the fnction that I am using for uploading my image files and it looks to me like there is an error in the width calclation – but I am not sure 😮
Here is the function:
[code=html]function makeThumbnail($source, $t_ht,$N_pix_n, $message2=NULL )
{
if(!($o_im = @imageCreateFromString(@file_get_contents($source))))
{
$message2 = “Error: The image supplied was corrupt or an invalid type!”;
return $message2;
}
$t_wd = round($t_ht * ($o_wd = imagesx($o_im)) / ($o_ht = imagesy($o_im))) ;
if(!($N_image = @imagecreatetruecolor($t_wd, $t_ht)))
{
$message2 = “Error: Problem with image dimensions!”;
return $message2;
}
imagecopyresampled($N_image, $o_im, 0, 0, 0, 0, $t_wd, $t_ht, $o_wd, $o_ht);
$destination = $_SERVER[‘DOCUMENT_ROOT’].”/images/$N_pix_n”;
if(!(@imageJPEG($N_image,$destination,90)))
{
$message2 = “Error: Could not save image!”;
return $message2;
}
imageDestroy($o_im);
imageDestroy($N_image);
} // End of Function
Now the $t_ht variable is = 225
but the calculation for the width is:
$t_wd = round($t_ht * ($o_wd = imagesx($o_im)) / ($o_ht = imagesy($o_im))) ;
This appears to have two or three equal signs in it ???
That can’t be correct can it ?
What I am trying to do is get a properly proportioned image that is
225px high and 300px wide.
Would much appreciate some maths help 😮