首页 > 开发 > PHP > 正文

php在新浪云中使用imagick的方法

2024-05-04 21:50:03
字体:
来源:转载
供稿:网友

php在新浪云中使用imagick生成缩略图并上传到Storage的方法

  1. <?php 
  2. //缩略图 
  3.     $tmpFile ='http://Vevb.com/original.jpg' ; 
  4.  
  5.     list($width$height) = getimagesize($tmpFile); 
  6.      
  7.     // resize if necessary 
  8.     if ($width >= 550 && $height >= 550) { 
  9.         $image = new Imagick($tmpFile); 
  10.         $image->thumbnailImage(550, 550,true); 
  11.     /* 上传文件到Storage */ 
  12.     $st = new SaeStorage(); 
  13.         $tmp_url = SAE_TMP_PATH.time();//保存到sae临时目录 
  14.     file_put_contents($tmp_url,$image);     
  15.     $path='/201608/22/1471856203_98548400.jpg'
  16.         if (!$st->upload('upload'$path$tmp_url)) {          
  17.             echo 0; 
  18.         } else { 
  19.             echo $st->getUrl('upload'$path); 
  20.         }//Vevb.com 
  21.     } 
  22. ?> 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表