Php 如何读取图像、调整大小并将调整大小的图像再次上载到rackspace容器

Php 如何读取图像、调整大小并将调整大小的图像再次上载到rackspace容器,php,image-resizing,rackspace-cloud,rackspace,Php,Image Resizing,Rackspace Cloud,Rackspace,我正在尝试此代码,但它不起作用 require('cloudfiles/cloudfiles.php'); $auth = new CF_Authentication($username, $key); $auth->authenticate(); $conn = new CF_Connection($auth); $container = $conn->get_container('images'); $localfile = $_FILES['

我正在尝试此代码,但它不起作用

require('cloudfiles/cloudfiles.php');

$auth = new CF_Authentication($username, $key);
$auth->authenticate();
$conn = new CF_Connection($auth);

$container = $conn->get_container('images');
                $localfile = $_FILES['upload']['tmp_name'];
                $ext = pathinfo($_FILES["upload"]['name'], PATHINFO_EXTENSION);
                $filename = "logos/xs/test-coupons-codes." . $ext;

                 // upload file to Rackspace
                $object = $container->create_object($filename);
                $object->load_from_filename($localfile);

                $obj = $container->get_object($filename); 
                $data = $obj->read();

                $size = 150;  // new image width
                $src = imagecreatefromstring($data); 
                $width = imagesx($src);
                $height = imagesy($src);
                $aspect_ratio = $height/$width;

                if ($width <= $size) {
                  $new_w = $width;
                  $new_h = $height;
                } else {
                  $new_w = $size;
                  $new_h = abs($new_w * $aspect_ratio);
                }

                $img = imagecreatetruecolor($new_w,$new_h); 
                imagecopyresized($img,$src,0,0,0,0,$new_w,$new_h,$width,$height);
                imagedestroy($src);

              imagejpeg($img); //you does not want to save.. just display

              $filename1 = "logos/s/test-coupons-codes.jpg";

                 // upload file to Rackspace
                 $object = $container->create_object($filename1);
                 $object->write($img);
                 //$object->load_from_filename($img);
imagedestroy($img);
require('cloudfiles/cloudfiles.php');
$auth=新的CF\U身份验证($username,$key);
$auth->authenticate();
$conn=新的CF\U连接($auth);
$container=$conn->get_container('images');
$localfile=$\u文件['upload']['tmp\u name'];
$ext=pathinfo($_文件[“上载”][“名称”],pathinfo_扩展名);
$filename=“logos/xs/测试优惠券代码”$提取;
//将文件上载到Rackspace
$object=$container->create_对象($filename);
$object->load_from_filename($localfile);
$obj=$container->get_对象($filename);
$data=$obj->read();
$size=150;//新图像宽度
$src=imagecreatefromstring($data);
$width=imagesx($src);
$height=imagesy($src);
$aspect_ratio=$height/$width;
if($width create_object($filename1);
$object->write($img);
//$object->load_from_filename($img);
图像处理(img);

为什么第一次上载图像?为什么不先调整大小然后再上载?@rdodev:因为我希望racksapace cloud Server中的两个图像都是您希望的,原始版本和调整大小的版本都是在CloudFiles中,对吗?@rdodev:是的,我希望两者都是。Rahul您能发布一个包含堆栈跟踪和错误的粘贴库吗?这样会这将有助于诊断您的问题。