所以我有一个场景,我必须将裁剪的图像上传到AWS。
首先,我有基本的图像上传工作(AWS putbucket 和所有),所以这不是问题。
我也有图像的裁剪工作(使用 imgAreaSelect),所以这也不是问题。
在PHP方面,我还从$_FILES['file']['tmp_name']中获取图像并创建一个新的裁剪图像(使用类似于 http://www.codeforest.net/how-to-crop-an-image-using-jquery-and-php 的代码。
但是我需要一种方法来获取在最后一行创建的新图像
imagejpeg($new, $new_filename, 95);
在 AWS 中放入 _FILES USD["文件"]["tmp_name"] 在此处上传
$s3->putObject(array(
'Body' => fopen($_FILES['file']['tmp_name'], 'r'),
));
所以:使用 GD
ob_start(); // start a new output buffer
imagejpeg( $dstImage, NULL, JPEG_QUALITY);
$resizedJpegData = ob_get_contents();
ob_end_clean(); // stop this output buffer
// free up unused memmory (if images are expected to be large)
unset($srcImage);
unset($dstImage);
// your resized jpeg data is now in $resizedJpegData
// Use your Undesigned method calls to store the data.
// (Many people want to send it as a Hex stream to the DB:)
$dbHandle->storeResizedImage( bin2hex($resizedJpegData) );
'Body' => fopen($dbHandle, 'r'),