The image you're trying to download is actually a PNG, not a JPEG.
Yes, I know the URL ends in .jpg
but that doesn't mean it is actually a JPEG image.
imagecreatefromstring()
is able to automatically detect supported image types from their header. So you should be able to do something like this:
$image_data = file_get_contents('http://www.example.com/image.jpg_or_png_or_whatever');
$img = imagecreatefromstring($image_data);