I\'m wanting to write some PHP code which automatically resizes any image uploaded via a form to 147x147px, but I have no idea how to go about it (I\'m a relative PHP novice
I would suggest an easy way:
function resize($file, $width, $height) {
switch(pathinfo($file)['extension']) {
case "png": return imagepng(imagescale(imagecreatefrompng($file), $width, $height), $file);
case "gif": return imagegif(imagescale(imagecreatefromgif($file), $width, $height), $file);
default : return imagejpeg(imagescale(imagecreatefromjpeg($file), $width, $height), $file);
}
}