Skip to content

Instantly share code, notes, and snippets.

@wyliethomas
Created May 6, 2011 19:27
Show Gist options
  • Save wyliethomas/959613 to your computer and use it in GitHub Desktop.
Save wyliethomas/959613 to your computer and use it in GitHub Desktop.
download image from remote
$image = 'http://some/path/to/a/image.jpg';
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $image);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0);
$file = curl_exec($ch);
curl_close($ch);
$newImg = imagecreatefromstring($file);
imagejpeg($newImg, "public/path/to/save/to.jpg",100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment