In case you are having trouble ( like I did ) and getting some kind of noise in the resampled image.
then changing imagecopyresampled() with imagecopyresized() removes the noise, found that here: http://bugs.php.net/bug.php?id=45030
Do not ask me why. but it works.