php convert user image to jpg
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/5060835/how-to-convert-all-images-to-jpg-format-in-php">How to convert all images to JPG format in PHP?</a>  </p>
</blockquote>



<p>I'm trying to pass the username into the filename and have the file end with .jpg  So the output would be "user-mycoolnewimage.jpg".  Any suggestions on how to do this as currently is changes to "randnumber-mycoolnewimage.png" which isn't what I want.  The random number doesn't help server logs and the image needs to end with jpg since it's being converted.</p>

<pre><code>$file = rand(0, 10000000).$_FILES['t1']['name'];
if (move_uploaded_file($_FILES['t1']['tmp_name'], $file)) {
    if($fp = fopen($file,"rb", 0)) {
        $picture = fread($fp,filesize($file));
        fclose($fp);
        $image = imagecreatefrompng($file);
        imagejpeg($image, $file, 70);
        imagedestroy($image);
        $tag1 = '&lt;img src="'.$file.'" alt="" class="default" /&gt;';
        //unlink($file);        
     }
}
</code></pre>
