changed imagecopyresized to imagecopyresampled for better image qualities