當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ImageHandler::normaliseParams方法代碼示例

本文整理匯總了PHP中ImageHandler::normaliseParams方法的典型用法代碼示例。如果您正苦於以下問題:PHP ImageHandler::normaliseParams方法的具體用法?PHP ImageHandler::normaliseParams怎麽用?PHP ImageHandler::normaliseParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ImageHandler的用法示例。


在下文中一共展示了ImageHandler::normaliseParams方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: normaliseParams

 /**
  * @param $image File
  * @param $params array Transform parameters. Entries with the keys 'width'
  * and 'height' are the respective screen width and height, while the keys
  * 'physicalWidth' and 'physicalHeight' indicate the thumbnail dimensions.
  * @return bool
  */
 function normaliseParams($image, &$params)
 {
     global $wgMaxImageArea;
     if (!parent::normaliseParams($image, $params)) {
         return false;
     }
     $mimeType = $image->getMimeType();
     # Obtain the source, pre-rotation dimensions
     $srcWidth = $image->getWidth($params['page']);
     $srcHeight = $image->getHeight($params['page']);
     # Don't make an image bigger than the source
     if ($params['physicalWidth'] >= $srcWidth) {
         $params['physicalWidth'] = $srcWidth;
         $params['physicalHeight'] = $srcHeight;
         # Skip scaling limit checks if no scaling is required
         # due to requested size being bigger than source.
         if (!$image->mustRender()) {
             return true;
         }
     }
     # Don't thumbnail an image so big that it will fill hard drives and send servers into swap
     # JPEG has the handy property of allowing thumbnailing without full decompression, so we make
     # an exception for it.
     # @todo FIXME: This actually only applies to ImageMagick
     if ($mimeType !== 'image/jpeg' && $srcWidth * $srcHeight > $wgMaxImageArea) {
         return false;
     }
     return true;
 }
開發者ID:namrenni,項目名稱:mediawiki,代碼行數:36,代碼來源:Bitmap.php

示例2: normaliseParams

 /**
  * @param File $image
  * @param array $params Transform parameters. Entries with the keys 'width'
  * and 'height' are the respective screen width and height, while the keys
  * 'physicalWidth' and 'physicalHeight' indicate the thumbnail dimensions.
  * @return bool
  */
 function normaliseParams($image, &$params)
 {
     if (!parent::normaliseParams($image, $params)) {
         return false;
     }
     # Obtain the source, pre-rotation dimensions
     $srcWidth = $image->getWidth($params['page']);
     $srcHeight = $image->getHeight($params['page']);
     # Don't make an image bigger than the source
     if ($params['physicalWidth'] >= $srcWidth) {
         $params['physicalWidth'] = $srcWidth;
         $params['physicalHeight'] = $srcHeight;
         # Skip scaling limit checks if no scaling is required
         # due to requested size being bigger than source.
         if (!$image->mustRender()) {
             return true;
         }
     }
     # Check if the file is smaller than the maximum image area for thumbnailing
     $checkImageAreaHookResult = null;
     wfRunHooks('BitmapHandlerCheckImageArea', array($image, &$params, &$checkImageAreaHookResult));
     if (is_null($checkImageAreaHookResult)) {
         global $wgMaxImageArea;
         if ($srcWidth * $srcHeight > $wgMaxImageArea && !($image->getMimeType() == 'image/jpeg' && self::getScalerType(false, false) == 'im')) {
             # Only ImageMagick can efficiently downsize jpg images without loading
             # the entire file in memory
             return false;
         }
     } else {
         return $checkImageAreaHookResult;
     }
     return true;
 }
開發者ID:Habatchii,項目名稱:wikibase-for-mediawiki,代碼行數:40,代碼來源:Bitmap.php

示例3: normaliseParams

 function normaliseParams($image, &$params)
 {
     global $wgMaxImageArea;
     if (!parent::normaliseParams($image, $params)) {
         return false;
     }
     $mimeType = $image->getMimeType();
     $srcWidth = $image->getWidth($params['page']);
     $srcHeight = $image->getHeight($params['page']);
     # Don't thumbnail an image so big that it will fill hard drives and send servers into swap
     # JPEG has the handy property of allowing thumbnailing without full decompression, so we make
     # an exception for it.
     if ($mimeType !== 'image/jpeg' && $srcWidth * $srcHeight > $wgMaxImageArea) {
         return false;
     }
     # Don't make an image bigger than the source
     $params['physicalWidth'] = $params['width'];
     $params['physicalHeight'] = $params['height'];
     if ($params['physicalWidth'] >= $srcWidth) {
         $params['physicalWidth'] = $srcWidth;
         $params['physicalHeight'] = $srcHeight;
         return true;
     }
     return true;
 }
開發者ID:amjadtbssm,項目名稱:website,代碼行數:25,代碼來源:Bitmap.php

示例4: normaliseParams

 function normaliseParams($image, &$params)
 {
     global $wgMaxThumbnailArea;
     wfProfileIn(__METHOD__);
     if (!ImageHandler::normaliseParams($image, $params)) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $params['physicalWidth'] = $params['width'];
     $params['physicalHeight'] = $params['height'];
     // Video files can be bigger than usuall images. We are alowing them to stretch up to WikiaFileHelper::maxWideoWidth px.
     if ($params['physicalWidth'] > WikiaFileHelper::maxWideoWidth) {
         $srcWidth = $image->getWidth($params['page']);
         $srcHeight = $image->getHeight($params['page']);
         $params['physicalWidth'] = WikiaFileHelper::maxWideoWidth;
         $params['physicalHeight'] = round($params['physicalWidth'] * $srcHeight / $srcWidth);
     }
     # Same as srcWidth * srcHeight above but:
     # - no free pass for jpeg
     # - thumbs should be smaller
     if ($params['physicalWidth'] * $params['physicalHeight'] > $wgMaxThumbnailArea) {
         wfProfileOut(__METHOD__);
         return false;
     }
     wfProfileOut(__METHOD__);
     return true;
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:27,代碼來源:VideoHandler.class.php

示例5: normaliseParams

 function normaliseParams($image, &$params)
 {
     if (!parent::normaliseParams($image, $params)) {
         return false;
     }
     $params['physicalWidth'] = $params['width'];
     $params['physicalHeight'] = $params['height'];
     return true;
 }
開發者ID:realsoc,項目名稱:mediawiki-extensions,代碼行數:9,代碼來源:FlvImageHandler.php

示例6: doFakeTransform

 /**
  * Override BitmapHandler::doTransform() making sure we do not generate
  * a thumbnail at all. That is merely returning a ThumbnailImage that
  * will be consumed by the unit test.  There is no need to create a real
  * thumbnail on the filesystem.
  * @param ImageHandler $that
  * @param File $image
  * @param string $dstPath
  * @param string $dstUrl
  * @param array $params
  * @param int $flags
  * @return ThumbnailImage
  */
 static function doFakeTransform($that, $image, $dstPath, $dstUrl, $params, $flags = 0)
 {
     # Example of what we receive:
     # $image: LocalFile
     # $dstPath: /tmp/transform_7d0a7a2f1a09-1.jpg
     # $dstUrl : http://example.com/images/thumb/0/09/Bad.jpg/320px-Bad.jpg
     # $params:  width: 320,  descriptionUrl http://trunk.dev/wiki/File:Bad.jpg
     $that->normaliseParams($image, $params);
     $scalerParams = ['physicalWidth' => $params['physicalWidth'], 'physicalHeight' => $params['physicalHeight'], 'physicalDimensions' => "{$params['physicalWidth']}x{$params['physicalHeight']}", 'clientWidth' => $params['width'], 'clientHeight' => $params['height'], 'comment' => isset($params['descriptionUrl']) ? "File source: {$params['descriptionUrl']}" : '', 'srcWidth' => $image->getWidth(), 'srcHeight' => $image->getHeight(), 'mimeType' => $image->getMimeType(), 'dstPath' => $dstPath, 'dstUrl' => $dstUrl];
     # In some cases, we do not bother generating a thumbnail.
     if (!$image->mustRender() && $scalerParams['physicalWidth'] == $scalerParams['srcWidth'] && $scalerParams['physicalHeight'] == $scalerParams['srcHeight']) {
         wfDebug(__METHOD__ . ": returning unscaled image\n");
         // getClientScalingThumbnailImage is protected
         return $that->doClientImage($image, $scalerParams);
     }
     return new ThumbnailImage($image, $dstUrl, false, $params);
 }
開發者ID:claudinec,項目名稱:galan-wiki,代碼行數:30,代碼來源:MockImageHandler.php

示例7: normaliseParams

 function normaliseParams($image, &$params)
 {
     global $wgSVGMaxSize;
     if (!parent::normaliseParams($image, $params)) {
         return false;
     }
     # Don't make an image bigger than wgMaxSVGSize
     $params['physicalWidth'] = $params['width'];
     $params['physicalHeight'] = $params['height'];
     if ($params['physicalWidth'] > $wgSVGMaxSize) {
         $srcWidth = $image->getWidth($params['page']);
         $srcHeight = $image->getHeight($params['page']);
         $params['physicalWidth'] = $wgSVGMaxSize;
         $params['physicalHeight'] = File::scaleHeight($srcWidth, $srcHeight, $wgSVGMaxSize);
     }
     return true;
 }
開發者ID:GodelDesign,項目名稱:Godel,代碼行數:17,代碼來源:SVG.php

示例8: normaliseParams

 /**
  * @param File $image
  * @param array $params Transform parameters. Entries with the keys 'width'
  * and 'height' are the respective screen width and height, while the keys
  * 'physicalWidth' and 'physicalHeight' indicate the thumbnail dimensions.
  * @return bool
  */
 function normaliseParams($image, &$params)
 {
     if (!parent::normaliseParams($image, $params)) {
         return false;
     }
     # Obtain the source, pre-rotation dimensions
     $srcWidth = $image->getWidth($params['page']);
     $srcHeight = $image->getHeight($params['page']);
     # Don't make an image bigger than the source
     if ($params['physicalWidth'] >= $srcWidth) {
         $params['physicalWidth'] = $srcWidth;
         $params['physicalHeight'] = $srcHeight;
         # Skip scaling limit checks if no scaling is required
         # due to requested size being bigger than source.
         if (!$image->mustRender()) {
             return true;
         }
     }
     return true;
 }
開發者ID:xfstudio,項目名稱:mediawiki,代碼行數:27,代碼來源:TransformationalImageHandler.php

示例9: normaliseParams

 /**
  * @param File $image
  * @param array $params
  * @return bool
  */
 function normaliseParams($image, &$params)
 {
     return ImageHandler::normaliseParams($image, $params);
 }
開發者ID:jpena88,項目名稱:mediawiki-dokku-deploy,代碼行數:9,代碼來源:Bitmap_ClientOnly.php

示例10: normaliseParams

	/**
	 * Prepares param array and sets standard values.
	 * Adds normalisation for parameter "lossy".
	 */
	function normaliseParams( $image, &$params ) {
		if ( !parent::normaliseParams( $image, $params ) ) {
			return false;
		}

		$data = $this->getMetaArray( $image );
		if ( !$data ) {
			return false;
		}

		if ( isset( $params['lossy'] ) ) {
			if ( in_array( $params['lossy'], array( 1, '1', 'true', 'lossy' ) ) ) {
				$params['lossy'] = 'lossy';
			} else {
				$params['lossy'] = 'lossless';
			}
		} else {
			$page = $this->adjustPage( $image, $params['page'] );

			if ( ( strtolower( $data['page_data'][$page]['alpha'] ) == 'true' ) ) {
				$params['lossy'] = 'lossless';
			} else {
				$params['lossy'] = 'lossy';
			}
		}

		return true;
	}
開發者ID:realsoc,項目名稱:mediawiki-extensions,代碼行數:32,代碼來源:PagedTiffHandler_body.php


注:本文中的ImageHandler::normaliseParams方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。