本文整理汇总了PHP中OC_Filesystem::getLocalPath方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Filesystem::getLocalPath方法的具体用法?PHP OC_Filesystem::getLocalPath怎么用?PHP OC_Filesystem::getLocalPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Filesystem
的用法示例。
在下文中一共展示了OC_Filesystem::getLocalPath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadFromFile
/**
* @brief Loads an image from a local file.
* @param $imageref The path to a local file.
* @returns An image resource or false on error
*/
public function loadFromFile($imagepath=false) {
if(!is_file($imagepath) || !file_exists($imagepath) || !is_readable($imagepath)) {
// Debug output disabled because this method is tried before loadFromBase64?
OC_Log::write('core', 'OC_Image->loadFromFile, couldn\'t load: '.$imagepath, OC_Log::DEBUG);
return false;
}
$itype = exif_imagetype($imagepath);
switch($itype) {
case IMAGETYPE_GIF:
if (imagetypes() & IMG_GIF) {
$this->resource = imagecreatefromgif($imagepath);
} else {
OC_Log::write('core', 'OC_Image->loadFromFile, GIF images not supported: '.$imagepath, OC_Log::DEBUG);
}
break;
case IMAGETYPE_JPEG:
if (imagetypes() & IMG_JPG) {
$this->resource = imagecreatefromjpeg($imagepath);
} else {
OC_Log::write('core', 'OC_Image->loadFromFile, JPG images not supported: '.$imagepath, OC_Log::DEBUG);
}
break;
case IMAGETYPE_PNG:
if (imagetypes() & IMG_PNG) {
$this->resource = imagecreatefrompng($imagepath);
} else {
OC_Log::write('core', 'OC_Image->loadFromFile, PNG images not supported: '.$imagepath, OC_Log::DEBUG);
}
break;
case IMAGETYPE_XBM:
if (imagetypes() & IMG_XPM) {
$this->resource = imagecreatefromxbm($imagepath);
} else {
OC_Log::write('core', 'OC_Image->loadFromFile, XBM/XPM images not supported: '.$imagepath, OC_Log::DEBUG);
}
break;
case IMAGETYPE_WBMP:
if (imagetypes() & IMG_WBMP) {
$this->resource = imagecreatefromwbmp($imagepath);
} else {
OC_Log::write('core', 'OC_Image->loadFromFile, WBMP images not supported: '.$imagepath, OC_Log::DEBUG);
}
break;
case IMAGETYPE_BMP:
$this->resource = $this->imagecreatefrombmp($imagepath);
break;
/*
case IMAGETYPE_TIFF_II: // (intel byte order)
break;
case IMAGETYPE_TIFF_MM: // (motorola byte order)
break;
case IMAGETYPE_JPC:
break;
case IMAGETYPE_JP2:
break;
case IMAGETYPE_JPX:
break;
case IMAGETYPE_JB2:
break;
case IMAGETYPE_SWC:
break;
case IMAGETYPE_IFF:
break;
case IMAGETYPE_ICO:
break;
case IMAGETYPE_SWF:
break;
case IMAGETYPE_PSD:
break;
*/
default:
// this is mostly file created from encrypted file
$this->resource = imagecreatefromstring(\OC_Filesystem::file_get_contents(\OC_Filesystem::getLocalPath($imagepath)));
$itype = IMAGETYPE_PNG;
OC_Log::write('core', 'OC_Image->loadFromFile, Default', OC_Log::DEBUG);
break;
}
if($this->valid()) {
$this->imagetype = $itype;
$this->filepath = $imagepath;
}
return $this->resource;
}