Creating an image without storing it as a local file

前端 未结 8 1014
时光取名叫无心
时光取名叫无心 2020-12-01 08:45

Here\'s my situation - I want to create a resized jpeg image from a user uploaded image, and then send it to S3 for storage, but am looking to avoid writing the resized jpeg

8条回答
  •  鱼传尺愫
    2020-12-01 08:59

    Pretty late to the game on this one, but if you are using the the S3 library mentioned by ConroyP and Imagick you should use the putObjectString() method instead of putObject() due the fact getImageBlob returns a string. Example that finally worked for me:

    $headers = array(
        'Content-Type' => 'image/jpeg'
    );
    $s3->putObjectString($im->getImageBlob(), $bucket, $file_name, S3::ACL_PUBLIC_READ, array(), $headers);
    

    I struggled with this one a bit, hopefully it helps someone else!

提交回复
热议问题