Howdy... I am trying to resize the uploaded image file if the dimension is not 650x450 or 135x135... I installed GD and I tried a sample code from the tutorial that generates JPG file, so I think GD is working... But I cannot have the code resize the image and overwrite it... Can someone see if there is anything wrong with the code???
This is a part of the file that I call to upload image file from the user's hard drive, and the file name is 'UploadFile.php'...
if ($theImageNum == 1)
{
if (($source_x != 650) && ($source_y != 450))
{
print("<SCRIPT>alert('Wrong dimension.');</SCRIPT>");
$dest_width = 650;
$dest_height = 450;
}
else
print("<SCRIPT>alert('Right dimension.');</SCRIPT>");
}
else if ($theImageNum >= 2)
{
if (($source_x != 135) && ($source_y != 135))
{
print("<SCRIPT>alert('Wrong dimension.');</SCRIPT>");
$dest_width = 135;
$dest_height = 135;
}
else
print("<SCRIPT>alert('Right dimension.');</SCRIPT>");
}
include('WriteImage.php');
and this is the 'WriteImage.php' that I think is supposed to write an actual image file...
<?
## WriteImage.php
Header("Content-type: image/jpeg");
print("<SCRIPT>alert('Writing an Image file...');</SCRIPT>");
$src_img = imagecreatefromjpeg($destination);
$dst_img = imagecreatetruecolor($dest_width, $dest_height);
imagecopyresized($dst_img, $src_img, 0 , 0 , 0 , 0, $dest_width, $dest_height, $source_x, $source_y);
// imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $source_x, $source_y);
imagejpeg($dst_img, $destination, 100);
imagedestroy($src_img);
imagedestroy($dst_img);
?>
I can see the alert message, so I know that the include() works, but I don't see the file gets resized at all... Can someone shed some light on me???
Thank you...
Jason
PHP 4.2.1
GD Support enabled
GD Version 1.6.2 or higher
FreeType Support enabled
FreeType Linkage with TTF library
JPG Support enabled
PNG Support enabled
WBMP Support enabled
Win2KP
IIS