Beispiel #1
0
 public function post($update, $after = null)
 {
     $api = new KStorage_Api();
     $content = $api->sRead($update['fileid']);
     if ('' === $content) {
         throw new Exception('获取原文件失败', 1);
     }
     if (false === ($info = Ko_Tool_Image::VInfo($content, Ko_Tool_Image::FLAG_SRC_BLOB))) {
         throw new Exception('获取原文件信息失败', 2);
     }
     $zoom = $info['width'] / $update['width'];
     $aOption = array('srcx' => $zoom * $update['left'], 'srcy' => $zoom * $update['top'], 'srcw' => $zoom * $update['w'], 'srch' => $zoom * $update['h'], 'quality' => 98, 'strip' => true);
     if (false === ($dst = Ko_Tool_Image::VCrop($content, '1.' . $info['type'], $update['w'], $update['h'], Ko_Tool_Image::FLAG_SRC_BLOB | Ko_Tool_Image::FLAG_DST_BLOB, $aOption))) {
         throw new Exception('文件转换失败', 3);
     }
     if (!$api->bContent2Storage($dst, $logoid)) {
         throw new Exception('文件保存失败', 3);
     }
     $loginApi = new KUser_loginApi();
     $baseinfoApi = new KUser_baseinfoApi();
     $baseinfoApi->bUpdateLogo($loginApi->iGetLoginUid(), $logoid);
     return array('key' => $logoid);
 }
Beispiel #2
0
 public function bContent2Storage($sContent, &$sDest, $bOnlyImage = true)
 {
     $imginfo = Ko_Tool_Image::VInfo($sContent, Ko_Tool_Image::FLAG_SRC_BLOB);
     if (false !== $imginfo) {
         $ret = $this->bWrite($sContent, $imginfo['type'], $sDest);
         if ($ret) {
             $this->_vSetSize($sDest, $imginfo['width'], $imginfo['height']);
         }
     } else {
         if (!$bOnlyImage) {
             $ret = $this->bWrite($sContent, '', $sDest);
         } else {
             $ret = false;
         }
     }
     return $ret;
 }
Beispiel #3
0
 public function bContent2Storage($sContent, &$sDest, $bOnlyImage = true)
 {
     $imginfo = Ko_Tool_Image::VInfo($sContent, Ko_Tool_Image::FLAG_SRC_BLOB);
     if (false !== $imginfo) {
         $ret = $this->bWrite($sContent, $imginfo['type'], $sDest);
         if ($ret) {
             if (5 <= $imginfo['orientation'] && $imginfo['orientation'] <= 8) {
                 $this->_vSetSize($sDest, $imginfo['height'], $imginfo['width']);
             } else {
                 $this->_vSetSize($sDest, $imginfo['width'], $imginfo['height']);
             }
             if (strlen($this->_aConf['exif']) && false !== ($exif = Ko_Tool_Image::VExif($sContent, Ko_Tool_Image::FLAG_SRC_BLOB))) {
                 $this->_vSetExif($sDest, $exif);
             }
         }
     } else {
         if (!$bOnlyImage) {
             $ret = $this->bWrite($sContent, '', $sDest);
         } else {
             $ret = false;
         }
     }
     return $ret;
 }