imagerotate option before or after move upload in php
<p>I have a form to upload a picture file, but i want to include an option to rotate the image in the same form.</p>

<p>What im not sure of, is should i rotate the image before saving it, or save it, open it, rotate it, then save it again. Im not sure what is the best method for accomplishing this. The code im using is below:</p>

<pre><code>$imagename = uniqid().".jpg";
if (file_exists("upload/" . $imagename))
    {
        //echo $_FILES["file"]["name"] . " already exists. ";
    } else {
        // Rotate image here before saving?
        move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $imagename);
        // Or open/rotate/resave image here?
}
</code></pre>
