当前位置: 首页>>代码示例>>PHP>>正文


PHP OC_Filesystem::getLocalPath方法代码示例

本文整理汇总了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;
	}
开发者ID:ryanshoover,项目名称:core,代码行数:89,代码来源:image.php


注:本文中的OC_Filesystem::getLocalPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。