本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例5: normaliseParams
function normaliseParams($image, &$params)
{
if (!parent::normaliseParams($image, $params)) {
return false;
}
$params['physicalWidth'] = $params['width'];
$params['physicalHeight'] = $params['height'];
return true;
}
示例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);
}
示例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;
}
示例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;
}
示例9: normaliseParams
/**
* @param File $image
* @param array $params
* @return bool
*/
function normaliseParams($image, &$params)
{
return ImageHandler::normaliseParams($image, $params);
}
示例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;
}