Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon s3 PHPThumb GdThumb,调整图像的2个变体大小,并将字符串保存到S3不工作_Amazon S3_Phpthumb - Fatal编程技术网

Amazon s3 PHPThumb GdThumb,调整图像的2个变体大小,并将字符串保存到S3不工作

Amazon s3 PHPThumb GdThumb,调整图像的2个变体大小,并将字符串保存到S3不工作,amazon-s3,phpthumb,Amazon S3,Phpthumb,我无法让下面的代码工作。我正在将原始图像保存到我的S3存储桶中,然后调整同一图像的两个变体的大小,并将PHPThumb_GdThumb生成的字符串发送到S3,但调整大小的图像有0kb并包含错误 图像可以很好地写入mybucket/object和mybucket/object/thumb中,但是thumb文件夹中的图像是0kb,并且包含错误 这是我的密码: // Add Original to S3 before doing any cropping $s3_path = 'my

我无法让下面的代码工作。我正在将原始图像保存到我的S3存储桶中,然后调整同一图像的两个变体的大小,并将PHPThumb_GdThumb生成的字符串发送到S3,但调整大小的图像有0kb并包含错误

图像可以很好地写入mybucket/objectmybucket/object/thumb中,但是thumb文件夹中的图像是0kb,并且包含错误

这是我的密码:

    // Add Original to S3 before doing any cropping

    $s3_path = 'mybucket/object';
    $S3_folder->addToBucket($s3_path.'/'.$filename, $path);


    $GDImage = new PHPThumb_GdThumb("{$path}");
    if (!$GDImage->getHasError())
    {
        // get images dimensions
        $dimensions = $GDImage->getCurrentDimensions();
        $imageWidth = (int) $dimensions['width'];
        $imageHeight = (int) $dimensions['height'];
        // thumbnails
        if ($imageHeight > $imageWidth)
        {
            $thumbPercent = floor(self::THUMB_SIZE / $imageHeight * 100);
        } else if ($imageHeight < $imageWidth)
        {
            $thumbPercent = floor(self::THUMB_SIZE / $imageWidth * 100);
        } else
        {
            // it's a square use either
            $thumbPercent = floor(self::THUMB_SIZE / $imageWidth * 100);
        }



        if ($imageHeight > self::THUMB_SIZE)
        {
            $img_string = $GDImage->resizePercent($thumbPercent)
                ->cropFromCenter(self::THUMB_SIZE)
                ->getImageAsString();


        } else
        {
            $img_string = $GDImage->getImageAsString();
        }


        $S3_folder->addToBucket($s3_path.'/thumb/'.$filename, $img_string);
//在进行任何裁剪之前,将原件添加到S3
$s3_path='mybucket/object';
$S3\u folder->addToBucket($S3\u path./'.$filename,$path);
$GDImage=newphpthumb_GdThumb(“{$path}”);
如果(!$GDImage->getHasError())
{
//获取图像尺寸
$dimensions=$GDImage->getCurrentDimensions();
$imageWidth=(int)$dimensions['width'];
$imageHeight=(int)$dimensions['height'];
//缩略图
如果($imageHeight>$imageWidth)
{
$thumbPercent=地板(自身::THUMB_尺寸/$imageHeight*100);
}else if($imageHeight<$imageWidth)
{
$thumbPercent=地板(自身::THUMB_尺寸/$imageWidth*100);
}否则
{
//这也是一个正方形的用法
$thumbPercent=地板(自身::THUMB_尺寸/$imageWidth*100);
}
如果($imageHeight>self::THUMB\u SIZE)
{
$img_string=$GDImage->resizePercent($thumbPercent)
->cropFromCenter(自身::拇指大小)
->getImageAsString();
}否则
{
$img_string=$GDImage->getImageAsString();
}
$S3\u folder->addToBucket($S3\u path./thumb/.$filename,$img\u string);

我已经成功地实现了这一点,但现在第二次调整速度很快,但将其发送到S3的速度非常慢,上传一个非常小的图像大约需要30秒


有人在一次将多个对象放入S3时遇到过问题吗?

你有没有想过?我即将走上与你相同的道路,如果你能分享一些知识,那就太好了!