Hi,
I'm writing a script that allows a user to upload images and then it checks to see if the height or width is greater than 600, if so, it resizes the whole thing down to a max width or height of 600. Its the resizing part of the script thats giving me problems, here it is, what am i doing wrong? The error I keep getting is "Warning: imagecopyresampled(): supplied argument is not a valid Image..." Any ideas?
$imagehw = GetImageSize( $upload_dir.$uploadedname );
imagecopyresampled( $upload_dir."copy".$uploadedname, $upload_dir.$uploadedname, 0, 0, 0, 0, $imagehw[0], $imagehw[1], $imagehw[0], $imagehw[1]);
if( $imagehw[0] > 600 || $imagehw[1] > 600 ) {
if( $imagehw[0] > $imagehw[1] ) {
$percent = 600 / $imagehw[0];
} else {
$percent = 600 / $imagehw[1];
}
$nwimagehw = array( $imagehw[0] * $percent, $imagehw[1] * $percent );
imagecopyresampled($upload_dir.$uploadedname, $upload_dir."copy".$uploadedname, 0, 0, 0, 0, $nwimagehw[0], $nwimagehw[1], $imagehw[0], $imagehw[1]);
}