The above code will pull an image and save it at the file location of temp_image.jpg.
$filename = 'http://www.yoursite.com/images/cowboybebop27.JPG';
$image = imagecreatefromjpeg($filename);
imagejpeg($image, null, 10);
imagejpeg($image, $dest, 10);
imagejpeg($image, null, 10); //This line displays the image with a quality of 10% which is roughly 1/10 the original file size as well.
You can read more about it here.
imagejpeg($image, $dest, 10); //This line saves the image with an image quality of 10%.