Something like this ... ?
<?php
/** define function to resize image **/
function resize($file, $path = '', $height = 300, $width = 400){
/** If array is not passed, use a variable */
$image = $path.$file;
/** Create a blank image */
$resize = imagecreatetruecolor($width, $height);
$quality = 75;
$size = getimagesize($image);
switch ($size['mime']) {
case 'image/jpeg':
$im = imagecreatefromjpeg($image);
imagecopyresampled($resize, $im, 0, 0, 0, 0, $width, $height, $size[0], $size[1]); // Resample the original JPEG
imagejpeg($resize, $image, $quality); // Output the new JPEG
break;
case 'image/jpg':
$im = imagecreatefromjpeg($image);
imagecopyresampled($resize, $im, 0, 0, 0, 0, $width, $height, $size[0], $size[1]); // Resample the original JPEG
imagejpeg($resize, $image, $quality); // Output the new JPEG
break;
case 'image/png':
$im = imagecreatefrompng($image);
imagecopyresampled($resize, $im, 0, 0, 0, 0, $width, $height, $size[0], $size[1]); // Resample the original PNG
imagepng($resize, $image, $quality); // Output the new PNG
break;
}
imagedestroy($im);
return true;
}
$file_handle= fopen('http://www.website.com', 'rb');
$data = fread($file_handle, 1024000);
$handle = fopen('local_image.jpg', 'wb');
fwrite($handle, $data);
fclose($handle);
$image = '/path/to/image/local_image.jpg';
resize($image);
?>
There may be a more efficient way to do this (manipulating the $data before saving it), but this should work (untested).