Possible Duplicate:
Calculating image size ratio for resizing
So I have a simple upload script that resizes the uploaded picture, I would like to force the width size, and let the height get automatically proportioned.
Here is my upload script:
if (isset($_POST['upload'])) {
        $dirupload = "../images/";
        $dirupload = $dirupload . basename( $_FILES['image-upload']['name']);
        $useless = $_POST['useless'];
        $imageupload = ($_FILES['image-upload']['name']);
        $uploadedfileupload = $_FILES['image-upload']['tmp_name'];
        $uploadedfiletypeupload = $_FILES['image-upload']['type']; 
        $query_add="SELECT * FROM produits ORDER BY position";
        $result_add=mysql_query($query_add);
        $num_add=mysql_num_rows($result_add);
        $add_add=$num_add+1;
        if (!($uploadedfiletypeupload =="image/pjpeg" OR $uploadedfiletypeupload =="image/jpeg" OR $uploadedfiletypeupload =="image/jpg")){
            echo "L'image doit être en .jpg ou .jpeg";
        }else if (move_uploaded_file($_FILES['image-upload']['tmp_name'], $dirupload)){     
            $sql="INSERT INTO produits (position) VALUES ('$add_add')";
            if (!mysql_query($sql,$con)){
                die('Error: ' . mysql_error());
            }       
            $newnameupload = "../images/produit" . mysql_insert_id() . ".jpg";
            rename ("../images/$imageupload","$newnameupload");    
            $orig_imageupload = imagecreatefromjpeg("../image/$newnameupload");
            $sm_imageupload = imagecreatetruecolor(274,219);
            imagecopyresampled($sm_imageupload,$orig_imageupload,0,0,0,0,274,219,imagesx($orig_imageupload),imagesy($orig_imageupload));
            imagejpeg($sm_imageupload, $newnameupload, 100);
        }else{
            echo "Un probleme est survenue";
        }
    }
Any ideas on trying to get this to work ? (yes I do have the height set for now in the script)
Thanks in advance !