Exemplo n.º 1
0
 public static function getImageInfo($img)
 {
     $imageInfo = FileUtil::imageSize($img);
     if ($imageInfo !== false) {
         $imageType = strtolower(substr(image_type_to_extension($imageInfo[2]), 1));
         $imageSize = FileUtil::fileSize($img);
         $info = array("width" => $imageInfo[0], "height" => $imageInfo[1], "type" => $imageType, "size" => $imageSize, "mime" => $imageInfo["mime"]);
         return $info;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 public function actionUploadAvatar()
 {
     $upload = FileUtil::getUpload($_FILES["Filedata"]);
     if (!$upload->save()) {
         $this->ajaxReturn(array("msg" => Ibos::lang("Save failed", "message"), "IsSuccess" => false));
     } else {
         $info = $upload->getAttach();
         $file = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachment"];
         $fileUrl = FileUtil::fileName($file);
         $tempSize = FileUtil::imageSize($fileUrl);
         if ($tempSize[0] < 180 || $tempSize[1] < 180) {
             $this->ajaxReturn(array("msg" => Ibos::lang("Avatar size error"), "IsSuccess" => false), "json");
         }
         $this->ajaxReturn(array("data" => $fileUrl, "file" => $file, "IsSuccess" => true));
     }
 }
Exemplo n.º 3
0
 public function open($imgname)
 {
     if (LOCAL && !FileUtil::fileExists($imgname)) {
         throw new Exception("不存在的图像文件:" . $imgname);
     }
     $info = FileUtil::imageSize(FileUtil::fileName($imgname));
     if (false === $info || IMAGETYPE_GIF === $info[2] && empty($info["bits"])) {
         throw new Exception("非法图像文件");
     }
     $this->info = array("width" => $info[0], "height" => $info[1], "type" => image_type_to_extension($info[2], false), "mime" => $info["mime"]);
     empty($this->img) || imagedestroy($this->img);
     if ("gif" == $this->info["type"]) {
         require_once "GIF.class.php";
         $this->gif = new GIF($imgname);
         $this->img = imagecreatefromstring($this->gif->image());
     } else {
         if (!LOCAL) {
             $imgname = Ibos::engine()->IO()->file()->fetchTemp(FileUtil::fileName($imgname), $this->info["type"]);
         }
         $fun = "imagecreatefrom{$this->info["type"]}";
         $this->img = $fun($imgname);
     }
 }
Exemplo n.º 4
0
 public function actionUploadIcon()
 {
     $upload = FileUtil::getUpload($_FILES["Filedata"]);
     if (!$upload->save()) {
         $this->ajaxReturn(array("msg" => Ibos::lang("Save failed", "message"), "isSuccess" => false));
     } else {
         $info = $upload->getAttach();
         $file = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachment"];
         $fileUrl = FileUtil::fileName($file);
         $tempSize = FileUtil::imageSize($fileUrl);
         if ($tempSize[0] < 64 || $tempSize[1] < 64) {
             $this->ajaxReturn(array("msg" => Ibos::lang("Icon size error"), "isSuccess" => false));
         }
         $this->ajaxReturn(array("imgurl" => $fileUrl, "aid" => $fileUrl, "name" => $info["name"], "isSuccess" => true));
     }
 }
Exemplo n.º 5
0
 protected function parseMarcroAttach($runID, $attachmentID, $showImg = true)
 {
     $attachDir = Ibos::app()->setting->get("setting/attachdir");
     $attach = AttachmentN::model()->fetch("rid:" . $runID, $attachmentID);
     if ($attach["isimage"] && $showImg) {
         $imgAttr = FileUtil::imageSize($attachDir . $attach["attachment"]);
         $attachLink = "<img src=\"{$attachDir}" . $attach["attachment"] . "\" {$imgAttr['3']} alt=\"{$attach["filename"]}\">";
         return $attachLink;
     }
     if ($this->flow->isFixed() && (StringUtil::findIn($this->process->attachpriv, "4") || !$this->process->attachpriv)) {
         $down = 1;
     } else {
         $down = 0;
     }
     if ($down) {
         $attachstr = AttachUtil::getAttachStr($attachmentID);
         $url = Ibos::app()->urlManager->createUrl("main/attach/download", array("id" => $attachstr));
         $link = "<a target=\"_blank\" class=\"xi2\" href=\"{$url}\">{$attach["filename"]}</a>";
     } else {
         $link = "<a class=\"xi2\" href=\"#\">{$attach["filename"]}</a>";
     }
     $type = StringUtil::getFileExt($attach["attach"]);
     $path = AttachUtil::attachType($type);
     $attachLink = "<span><img src=\"{$path}\">{$link}</span>";
     return $attachLink;
 }
Exemplo n.º 6
0
 private function uploadAvatar()
 {
     $upload = FileUtil::getUpload($_FILES["Filedata"]);
     if (!$upload->save()) {
         $this->ajaxReturn(array("msg" => Ibos::lang("Save failed", "message"), "IsSuccess" => false));
     } else {
         $info = $upload->getAttach();
         $file = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachment"];
         $fileUrl = FileUtil::fileName($file);
         $tempSize = FileUtil::imageSize($fileUrl);
         if ($tempSize[0] < 180 || $tempSize[1] < 180) {
             $this->ajaxReturn(array("msg" => Ibos::lang("Avatar size error"), "IsSuccess" => false), "json");
         }
         Ibos::import("ext.ThinkImage.ThinkImage", true);
         $imgObj = new ThinkImage(THINKIMAGE_GD);
         $imgTemp = $imgObj->open($fileUrl);
         $params = array("w" => $imgTemp->width(), "h" => $imgTemp->height(), "x" => "0", "y" => "0");
         if ($params["h"] < $params["w"]) {
             $params["x"] = ($params["w"] - $params["h"]) / 2;
             $params["w"] = $params["h"];
         } else {
             $params["y"] = ($params["h"] - $params["w"]) / 2;
             $params["h"] = $params["w"];
         }
         $imgObj->open($fileUrl)->crop($params["w"], $params["h"], $params["x"], $params["y"])->save($fileUrl);
         $this->ajaxReturn(array("data" => $fileUrl, "file" => $fileUrl, "IsSuccess" => true));
     }
 }