本文整理汇总了PHP中FileUtil::imageSize方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtil::imageSize方法的具体用法?PHP FileUtil::imageSize怎么用?PHP FileUtil::imageSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtil
的用法示例。
在下文中一共展示了FileUtil::imageSize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getImageInfo
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;
}
}
示例2: actionUploadAvatar
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));
}
}
示例3: open
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);
}
}
示例4: actionUploadIcon
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));
}
}
示例5: parseMarcroAttach
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;
}
示例6: uploadAvatar
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));
}
}