zoukankan      html  css  js  c++  java
  • SAE 合并图片

     1 $domain = 'picleader';                          //图片库的域名
     2 $stgurl = 'http://lemonluoxing-picleader.stor.sinaapp.com/';    //绝对路径
     3 //$storage = new Storage($domain,$stgurl);
     4 $storage = new SaeStorage();                        
     5 
     6 
     7 //echo "<!--".."-->";
     8 echo "<!--" . $destPath . "-->";
     9 $times = $_POST['times'];                       //图片的缩放比例
    10 echo "<!--" . $times . "-->";
    11 
    12 
    13 //调用页面的getuserid 函数, 修改userid值, 方便后面选择头像
    14 
    15 $type = $_POST['type'];                       //图片类型
    16 echo "<!--" . $type . "-->";
    17 
    18 switch ($type) {
    19 case 1: 
    20 $im = imagecreatefromgif($destPath);              //type为1 , gif
    21 break;
    22 case 2:
    23 $im = imagecreatefromjpeg($destPath);             //type为2 , jpeg
    24 break;
    25 case 3:
    26 $im = imagecreatefrompng($destPath);              //type为3, png
    27 break;
    28 }
    29 
    30 $newpath = "avatars/" . $userid . ".jpg"; //-------------新图像的文件名----
    31 
    32 $thumb = imagecreatetruecolor(200, 200); //------------创建新图-----
    33 $thumbWidth = $_POST['w']; 
    34 $thumbHeight = $_POST['h'];                   //裁剪头像的高和宽
    35 $w=$thumbWidth*$times;
    36 $h=$thumbHeight*$times;
    37 $x1 = $_POST['x1']*$times; 
    38 $y1 = $_POST['y1']*$times;                    //裁剪头像的起始坐标
    39 
    40 ob_start(); //开启缓存
    41 
    42 imagecopyresampled($thumb, $im,0,0,$x1,$y1,200,200,$w,$h);     //把原图对齐到新图上(新图是200×200)
    43 imagejpeg($thumb);                            
    44 $imgstr = ob_get_contents();                      //得到缓存的图片
    45 //$storage->saveimage($newpath,$imgstr);
    46 $storage->write($domain,$newpath,$imgstr);              //储存图片
    47 ob_end_clean();                              //关闭缓存
  • 相关阅读:
    滚动到Table的某个位置
    前端导出可修改样式的Excel表格
    在vue中绑定weui的class
    html5的消息通知
    在nginx上部署页面,使用ip访问页面,实现跨设备访问本地静态页面
    用原生javascript实现get请求,及具体数据的获取
    vue中如何实现图片不存在时显示一个默认的图片
    css选择器
    javascript 类型及类型判断
    CSS
  • 原文地址:https://www.cnblogs.com/Fadinglemon/p/3907028.html
Copyright © 2011-2022 走看看