title: How to resize an image retrieved by file_get_contents and save it in a folder?
body: <p>I want to retrieve image from a URL, resize it and save it to folder. </p>
  
  <p>I have this code to retrieve image from url : </p>
  
  <pre><code>$url = 'http://www.example.com/image/test.jpg';
  $img = 'images/newtest.jpg';    
  file_put_contents($img, file_get_contents($url));
  </code></pre>
  
  <p>The problem is that before doing <code>file_put_contents</code>, I want to resize the image. How can I do it with php? Please Help me, I have searched on the internet but ended up with unclear explanation.</p>