获取远程映像并上载到AWS S3

I'm trying to fetch a remote image, resize it, and upload it to AWS S3, and I'm getting an error that I don't know how to resolve.

Here's my code:

//Fetch and resize remote image
$max_width = 800;
$remote_img = file_get_contents("https://commons.wikimedia.org/wiki/Stovall_House#/media/File:Tampa_Stovall_House_gazebo01.jpg");
$im = imagecreatefromstring($remote_img);
$remote_img_width = imagesx($im);
$remote_img_height = imagesy($im);
if($remote_img_width<=$max_width){
    $saved_img_width = $remote_img_width;
    $saved_img_height = $remote_img_height;
    } else {
    $saved_img_width = $max_width;
    $ratio = $max_width/$remote_img_width;
    $saved_img_height = $remote_img_height * $ratio;
    }
$saved_image = imagecreatetruecolor($saved_img_width, $saved_img_height);
imagecopyresized($saved_image , $im, 0, 0, 0, 0, $saved_img_width, $saved_img_height, $remote_img_width, $remote_img_height);

//Upload to AWS S3
require 'aws/aws-autoloader.php';
use Aws\S3\S3Client;
$s3 = new Aws\S3\S3Client([
    'version'     => 'latest',
    'region'      => 'us-east-1',
    'credentials' => [
        'key'    => 'ABCD1234',
        'secret' => 'ABCD1234'
        ]
    ]);
$result = $s3->putObject(array(
        'Bucket' => 'aws-website-virulous-bebmb',
        'Key'    => 'ABCD1234',
        'Body'   => $saved_image,
        'ACL'    => 'public-read'
    ));

// Get the URL the object can be downloaded from and display
$image_url = $result['ObjectURL'];
echo "The image can be seen at <a href='" . $image_url . "' target='_new'>" . $image_url . "</a>";

//Clean up
imagedestroy($saved_image); 
imagedestroy($im);

And here's the error I'm getting:

Fatal error: Uncaught InvalidArgumentException: Found 1 error while validating the input provided for the PutObject operation: [Body] must be an fopen resource, a GuzzleHttp\Stream\StreamInterface object, or something that can be cast to a string.

What am I doing wrong?

Well it would be more beneficial to suggest to you that you take your error message, and perform a search on Google, as there are Lots of HITS and lots of explanations.

One of the suggestions in the error message

[Body] must be an fopen resource

Which Hints that you need to have saved your final image and open it using fopen passing the handle to body instead of $saved_image.

There's a few references you can hunt down regarding this on Google and in the AWS API.