title: laravel and image intervention, how to convert all images to jpeg and save from Input::file?
body: <p>I have read the documentations on image intervention implementation on laravel and i did it successfully i have also read the documentations on how to use the intervention but i can't seems to figure out how to convert all uploaded images to jpg and to save them to desired path with .jpg extension.</p>
  
  <p>This is my code so far, it's working but with few glitches.</p>
  
  <pre><code> Image::make(Input::file('avatarfull'))-&gt;fit('192', '192')-&gt;save(base_path() . '/img/' . $imagename .'.jpg')-&gt;encode('jpg', 80);
  </code></pre>
  
  <p>So what i want to achieve is:</p>
  
  <ul>
  <li>Take the uploaded image from Input::file('avatarfull') </li>
  <li>Use intervention package to grab the image Image::make(Input::file('avatarfull')</li>
  <li>Resize the image to desired width and height ->fit()</li>
  <li>Save the image to desired path ->save</li>
  <li>And encode all the images to jpg format ->encode</li>
  </ul>
  
  <p>This is all from documentation from intervention website.</p>
  
  <ul>
  <li>fit() should crop and resize image to desired width and height</li>
  <li>save() will move the image and save to desired path</li>
  <li>encode() should convert any image (bmp, png, gif) to jpg format.</li>
  </ul>
  
  <p>But in the proccess something gets wrong so i end up with image with no extension at all in my img folder and images doesn't get converted to jpg format. If i upload png it stays png.</p>
  
  <p>For the record i decided to use random string for uploaded images, so </p>
  
  <pre><code>$imagename = str_random(20);
  </code></pre>
  
  <p>Because i saw that my images get's saved only with random string name, so with uploaded image i end up with a name like:</p>
  
  <pre><code>MSm72XvEWE8AlCUvpHvX
  </code></pre>
  
  <p>I decided to add .jpg extension manually as you can see</p>
  
  <pre><code>-&gt;save(base_path() . '/img/' . $imagename .'.jpg')
  </code></pre>
  
  <p>And this saves the image with a random string name and .jpg extension at the end. </p>
  
  <p>But problem with converting images to jpg still exists so when i upload png image i get now MSm72XvEWE8AlCUvpHvX.jpg but when i check the image in browser it have transparent background, when i checked properties the image is still png, it just have forced .jpg name because i added that to the save().</p>
  
  <p>Is there a way so all the images gets converted to jpg and also to automatically write the image name with .jpg extension or i have to name that manually ?</p>