MediaWiki  REL1_23
BitmapHandler Class Reference

Generic handler for bitmap images. More...

Inheritance diagram for BitmapHandler:
Collaboration diagram for BitmapHandler:

List of all members.

Public Member Functions

 doTransform ($image, $dstPath, $dstUrl, $params, $flags=0)
 escapeMagickInput ($path, $scene=false)
 Escape a string for ImageMagick's input filenames.
 escapeMagickOutput ($path, $scene=false)
 Escape a string for ImageMagick's output filename.
 escapeMagickProperty ($s)
 Escape a string for ImageMagick's property input (e.g.
 extractPreRotationDimensions ($params, $rotation)
 Extracts the width/height if the image will be scaled before rotating.
 getMediaTransformError ($params, $errMsg)
 Get a MediaTransformError with error 'thumbnail_error'.
 mustRender ($file)
 Rerurns whether the file needs to be rendered.
 normaliseParams ($image, &$params)
 rotate ($file, $params)

Static Public Member Functions

static autoRotateEnabled ()
static canRotate ()
 Returns whether the current scaler supports rotation (im and gd do)
static imageJpegWrapper ($dst_image, $thumbPath)

Protected Member Functions

 escapeMagickPath ($path, $scene=false)
 Armour a string against ImageMagick's GetPathComponent().
 getClientScalingThumbnailImage ($image, $scalerParams)
 Get a ThumbnailImage that respresents an image that will be scaled client side.
 getMagickVersion ()
 Retrieve the version of the installed ImageMagick You can use PHPs version_compare() to use this value Value is cached for one hour.
 transformCustom ($image, $params)
 Transform an image using a custom command.
 transformGd ($image, $params)
 Transform an image using the built in GD library.
 transformImageMagick ($image, $params)
 Transform an image using ImageMagick.
 transformImageMagickExt ($image, $params)
 Transform an image using the Imagick PHP extension.

Static Protected Member Functions

static getScalerType ($dstPath, $checkDstPath=true)
 Returns which scaler type should be used.

Detailed Description

Generic handler for bitmap images.

Definition at line 29 of file Bitmap.php.


Member Function Documentation

static BitmapHandler::autoRotateEnabled ( ) [static]
See also:
$wgEnableAutoRotation
Returns:
bool Whether auto rotation is enabled

Definition at line 766 of file Bitmap.php.

References canRotate(), and global.

Referenced by ExifBitmapHandler\getImageSize(), and ExifBitmapHandler\getRotation().

static BitmapHandler::canRotate ( ) [static]

Returns whether the current scaler supports rotation (im and gd do)

Returns:
bool

Reimplemented from MediaHandler.

Definition at line 743 of file Bitmap.php.

References getScalerType().

Referenced by autoRotateEnabled(), ResourceLoaderStartUpModule\getConfig(), mustRender(), ExifRotationTest\testMetadata(), and ExifRotationTest\testRotationRendering().

BitmapHandler::doTransform ( image,
dstPath,
dstUrl,
params,
flags = 0 
)
Parameters:
File$image
string$dstPath
string$dstUrl
array$params
int$flags
Returns:
MediaTransformError|ThumbnailImage|TransformParameterError

Reimplemented from MediaHandler.

Reimplemented in BitmapHandler_ClientOnly, and MockBitmapHandler.

Definition at line 116 of file Bitmap.php.

References $flags, $params, array(), as, getClientScalingThumbnailImage(), getScalerType(), normaliseParams(), of, on, page, MediaHandler\removeBadFile(), text, transformCustom(), transformGd(), transformImageMagick(), transformImageMagickExt(), wfDebug(), wfDebugLog(), wfHostname(), wfMessage(), wfMkdirParents(), wfRunHooks(), and will.

BitmapHandler::escapeMagickInput ( path,
scene = false 
)

Escape a string for ImageMagick's input filenames.

See ExpandFilenames() and GetPathComponent() in magick/utility.c.

This won't work with an initial ~ or @, so input files should be prefixed with the directory name.

Glob character unescaping is broken in ImageMagick before 6.6.1-5, but it's broken in a way that doesn't involve trying to convert every file in a directory, so we're better off escaping and waiting for the bugfix to filter down to users.

Parameters:
string$pathThe file path
bool | string$sceneThe scene specification, or false if there is none
Exceptions:
MWException
Returns:
string

Definition at line 643 of file Bitmap.php.

References $path, and escapeMagickPath().

Referenced by rotate(), and transformImageMagick().

BitmapHandler::escapeMagickOutput ( path,
scene = false 
)

Escape a string for ImageMagick's output filename.

See InterpretImageFilename() in magick/image.c.

Parameters:
string$pathThe file path
bool | string$sceneThe scene specification, or false if there is none
Returns:
string

Definition at line 663 of file Bitmap.php.

References $path, and escapeMagickPath().

Referenced by rotate(), and transformImageMagick().

BitmapHandler::escapeMagickPath ( path,
scene = false 
) [protected]

Armour a string against ImageMagick's GetPathComponent().

This is a helper function for escapeMagickInput() and escapeMagickOutput().

Parameters:
string$pathThe file path
bool | string$sceneThe scene specification, or false if there is none
Exceptions:
MWException
Returns:
string

Definition at line 678 of file Bitmap.php.

References $path, and wfIsWindows().

Referenced by escapeMagickInput(), and escapeMagickOutput().

Escape a string for ImageMagick's property input (e.g.

-set -comment) See InterpretImageProperties() in magick/property.c

Parameters:
string$s
Returns:
string

Definition at line 613 of file Bitmap.php.

References $s.

Referenced by transformImageMagick().

BitmapHandler::extractPreRotationDimensions ( params,
rotation 
)

Extracts the width/height if the image will be scaled before rotating.

This will match the physical size/aspect ratio of the original image prior to application of the rotation -- so for a portrait image that's stored as raw landscape with 90-degress rotation, the resulting size will be wider than it is tall.

Parameters:
array$paramsParameters as returned by normaliseParams
int$rotationThe rotation angle that will be applied
Returns:
array ($width, $height) array

Definition at line 95 of file Bitmap.php.

References $params, and array().

Referenced by transformGd(), transformImageMagick(), and transformImageMagickExt().

BitmapHandler::getClientScalingThumbnailImage ( image,
scalerParams 
) [protected]

Get a ThumbnailImage that respresents an image that will be scaled client side.

Parameters:
File$imageFile associated with this thumbnail
array$scalerParamsArray with scaler params
Returns:
ThumbnailImage
Todo:
FIXME: No rotation support

Definition at line 288 of file Bitmap.php.

References $params, and array().

Referenced by MockBitmapHandler\doClientImage(), and doTransform().

Retrieve the version of the installed ImageMagick You can use PHPs version_compare() to use this value Value is cached for one hour.

Returns:
string Representing the IM version.

Definition at line 709 of file Bitmap.php.

References $cache, $matches, $retval, $wgMemc, global, wfDebug(), wfEscapeShellArg(), and wfShellExec().

Referenced by transformImageMagick().

BitmapHandler::getMediaTransformError ( params,
errMsg 
)

Get a MediaTransformError with error 'thumbnail_error'.

Parameters:
array$paramsParameter array as passed to the transform* functions
string$errMsgError message
Returns:
MediaTransformError

Definition at line 514 of file Bitmap.php.

References $params.

Referenced by transformCustom(), transformGd(), transformImageMagick(), and transformImageMagickExt().

static BitmapHandler::getScalerType ( dstPath,
checkDstPath = true 
) [static, protected]

Returns which scaler type should be used.

Creates parent directories for $dstPath and returns 'client' on error

Parameters:
string$dstPath
bool$checkDstPath
Returns:
string One of client, im, custom, gd, imext

Reimplemented in XCFHandler.

Definition at line 255 of file Bitmap.php.

References global.

Referenced by canRotate(), doTransform(), normaliseParams(), and rotate().

static BitmapHandler::imageJpegWrapper ( dst_image,
thumbPath 
) [static]

Definition at line 733 of file Bitmap.php.

Rerurns whether the file needs to be rendered.

Returns true if the file requires rotation and we are able to rotate it.

Parameters:
File$file
Returns:
bool

Reimplemented from MediaHandler.

Reimplemented in TiffHandler, XCFHandler, and BmpHandler.

Definition at line 836 of file Bitmap.php.

References $file, canRotate(), and MediaHandler\getRotation().

BitmapHandler::normaliseParams ( image,
&$  params 
)
Parameters:
File$image
array$paramsTransform 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.
Returns:
bool

Reimplemented from ImageHandler.

Reimplemented in BitmapHandler_ClientOnly.

Definition at line 37 of file Bitmap.php.

References $params, array(), getScalerType(), global, and wfRunHooks().

Referenced by doTransform(), and BitmapScalingTest\testNormaliseParams().

BitmapHandler::rotate ( file,
params 
)
Parameters:
File$file
array$paramsRotate parameters. 'rotation' clockwise rotation in degrees, allowed are multiples of 90
Since:
1.21
Returns:
bool

Reimplemented in JpegHandler.

Definition at line 784 of file Bitmap.php.

References $file, $params, $result, $retval, escapeMagickInput(), escapeMagickOutput(), MediaHandler\getRotation(), getScalerType(), global, MediaHandler\logErrorForExternalProcess(), wfDebug(), wfEscapeShellArg(), wfProfileIn(), wfProfileOut(), and wfShellExecWithStderr().

BitmapHandler::transformCustom ( image,
params 
) [protected]

Transform an image using a custom command.

Parameters:
File$imageFile associated with this thumbnail
array$paramsArray with scaler params
Returns:
MediaTransformError Error object if error occurred, false (=no error) otherwise

Definition at line 481 of file Bitmap.php.

References $params, $retval, getMediaTransformError(), global, MediaHandler\logErrorForExternalProcess(), wfDebug(), wfEscapeShellArg(), wfProfileIn(), wfProfileOut(), and wfShellExecWithStderr().

Referenced by doTransform().

BitmapHandler::transformGd ( image,
params 
) [protected]

Transform an image using the built in GD library.

Parameters:
File$imageFile associated with this thumbnail
array$paramsArray with scaler params
Returns:
MediaTransformError Error object if error occurred, false (=no error) otherwise

Definition at line 527 of file Bitmap.php.

References $params, array(), extractPreRotationDimensions(), getMediaTransformError(), MediaHandler\getRotation(), list, wfDebug(), and wfMessage().

Referenced by doTransform().

BitmapHandler::transformImageMagick ( image,
params 
) [protected]

Transform an image using ImageMagick.

Parameters:
File$imageFile associated with this thumbnail
array$paramsArray with scaler params
Returns:
MediaTransformError Error object if error occurred, false (=no error) otherwise

Definition at line 305 of file Bitmap.php.

References $params, $retval, array(), escapeMagickInput(), escapeMagickOutput(), escapeMagickProperty(), extractPreRotationDimensions(), ImageHandler\getImageArea(), getMagickVersion(), getMediaTransformError(), MediaHandler\getRotation(), global, MediaHandler\isAnimatedImage(), list, MediaHandler\logErrorForExternalProcess(), wfDebug(), wfProfileIn(), wfProfileOut(), and wfShellExecWithStderr().

Referenced by doTransform().

BitmapHandler::transformImageMagickExt ( image,
params 
) [protected]

Transform an image using the Imagick PHP extension.

Parameters:
File$imageFile associated with this thumbnail
array$paramsArray with scaler params
Returns:
MediaTransformError Error object if error occurred, false (=no error) otherwise

Definition at line 405 of file Bitmap.php.

References $e, $params, $result, as, extractPreRotationDimensions(), ImageHandler\getImageArea(), getMediaTransformError(), MediaHandler\getRotation(), global, MediaHandler\isAnimatedImage(), list, and wfDebug().

Referenced by doTransform().


The documentation for this class was generated from the following file: