MediaWiki  REL1_19
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.
 getImageArea ($image)
 Function that returns the number of pixels to be thumbnailed.
 getMediaTransformError ($params, $errMsg)
 Get a MediaTransformError with error 'thumbnail_error'.
 getRotation ($file)
 On supporting image formats, try to read out the low-level orientation of the file and return the angle that the file needs to be rotated to be viewed.
 mustRender ($file)
 Rerurns whether the file needs to be rendered.
 normaliseParams ($image, &$params)

Static Public Member Functions

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, $params)
 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.
 logErrorForExternalProcess ($retval, $err, $cmd)
 Log an error that occured in an external process.
 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 14 of file Bitmap.php.


Member Function Documentation

static BitmapHandler::canRotate ( ) [static]

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

Returns:
bool

Definition at line 714 of file Bitmap.php.

References getScalerType().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from MediaHandler.

Reimplemented in BitmapHandler_ClientOnly.

Definition at line 108 of file Bitmap.php.

References getClientScalingThumbnailImage(), getScalerType(), normaliseParams(), MediaHandler\removeBadFile(), transformCustom(), transformGd(), transformImageMagick(), transformImageMagickExt(), wfDebug(), wfMkdirParents(), and wfRunHooks().

Here is the call graph for this function:

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:
$pathstring The file path
$scenestring The scene specification, or false if there is none

Definition at line 605 of file Bitmap.php.

References $path, and escapeMagickPath().

Referenced by transformImageMagick().

Here is the call graph for this function:

Here is the caller graph for this function:

BitmapHandler::escapeMagickOutput ( path,
scene = false 
)

Escape a string for ImageMagick's output filename.

See InterpretImageFilename() in magick/image.c.

Definition at line 622 of file Bitmap.php.

References $path, and escapeMagickPath().

Referenced by transformImageMagick().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Armour a string against ImageMagick's GetPathComponent().

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

Parameters:
$pathstring The file path
$scenestring The scene specification, or false if there is none

Definition at line 634 of file Bitmap.php.

References $path, and wfIsWindows().

Referenced by escapeMagickInput(), and escapeMagickOutput().

Here is the call graph for this function:

Here is the caller graph for this function:

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

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

Definition at line 578 of file Bitmap.php.

Referenced by transformImageMagick().

Here is the caller graph for this function:

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:
$paramsarray Parameters as returned by normaliseParams
$rotationint The rotation angle that will be applied
Returns:
array ($width, $height) array

Definition at line 76 of file Bitmap.php.

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

Here is the caller graph for this function:

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

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

Parameters:
$imageFile File associated with this thumbnail
$paramsarray Array with scaler params
Returns:
ThumbnailImage

no rotation support

Definition at line 251 of file Bitmap.php.

Referenced by doTransform().

Here is the caller graph for this function:

Function that returns the number of pixels to be thumbnailed.

Intended for animated GIFs to multiply by the number of frames.

Parameters:
File$image
Returns:
int

Reimplemented in GIFHandler.

Definition at line 96 of file Bitmap.php.

Referenced by transformImageMagick(), and transformImageMagickExt().

Here is the caller graph for this function:

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 664 of file Bitmap.php.

References $matches, $wgImageMagickConvertCommand, $wgMemc, wfDebug(), wfEscapeShellArg(), and wfShellExec().

Referenced by transformImageMagick().

Here is the call graph for this function:

Here is the caller graph for this function:

BitmapHandler::getMediaTransformError ( params,
errMsg 
)

Get a MediaTransformError with error 'thumbnail_error'.

Parameters:
$paramsarray Parameter array as passed to the transform* functions
$errMsgstring Error message
Returns:
MediaTransformError

Definition at line 485 of file Bitmap.php.

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

Here is the caller graph for this function:

On supporting image formats, try to read out the low-level orientation of the file and return the angle that the file needs to be rotated to be viewed.

This information is only useful when manipulating the original file; the width and height we normally work with is logical, and will match any produced output views.

The base BitmapHandler doesn't understand any metadata formats, so this is left up to child classes to implement.

Parameters:
$fileFile
Returns:
int 0, 90, 180 or 270

Reimplemented in ExifBitmapHandler.

Definition at line 705 of file Bitmap.php.

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

Here is the caller graph for this function:

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

Returns:
string client,im,custom,gd

Reimplemented in XCFHandler.

Definition at line 219 of file Bitmap.php.

References $wgCustomConvertCommand, $wgUseImageMagick, and $wgUseImageResize.

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

Here is the caller graph for this function:

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

Definition at line 685 of file Bitmap.php.

BitmapHandler::logErrorForExternalProcess ( retval,
err,
cmd 
) [protected]

Log an error that occured in an external process.

Parameters:
$retvalint
$errint
$cmdstring

Definition at line 473 of file Bitmap.php.

References wfDebugLog(), and wfHostname().

Referenced by transformCustom(), and transformImageMagick().

Here is the call graph for this function:

Here is the caller graph for this function:

Rerurns whether the file needs to be rendered.

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

Parameters:
$fileFile
Returns:
bool

Reimplemented from MediaHandler.

Reimplemented in TiffHandler, XCFHandler, and BmpHandler.

Definition at line 740 of file Bitmap.php.

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

Here is the call graph for this function:

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

Reimplemented from ImageHandler.

Reimplemented in BitmapHandler_ClientOnly.

Definition at line 22 of file Bitmap.php.

References $wgMaxImageArea, getScalerType(), and wfRunHooks().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Transform an image using a custom command.

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

Definition at line 442 of file Bitmap.php.

References $wgCustomConvertCommand, getMediaTransformError(), logErrorForExternalProcess(), wfDebug(), wfEscapeShellArg(), wfProfileIn(), wfProfileOut(), and wfShellExec().

Referenced by doTransform().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Transform an image using the built in GD library.

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

Definition at line 498 of file Bitmap.php.

References extractPreRotationDimensions(), getMediaTransformError(), getRotation(), wfDebug(), and wfMsg().

Referenced by doTransform().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Transform an image using ImageMagick.

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

Definition at line 264 of file Bitmap.php.

References $wgImageMagickConvertCommand, $wgImageMagickTempDir, $wgMaxAnimatedGifArea, $wgSharpenParameter, $wgSharpenReductionThreshold, escapeMagickInput(), escapeMagickOutput(), escapeMagickProperty(), extractPreRotationDimensions(), getImageArea(), getMagickVersion(), getMediaTransformError(), getRotation(), ImageHandler\isAnimatedImage(), logErrorForExternalProcess(), wfDebug(), wfProfileIn(), wfProfileOut(), and wfShellExec().

Referenced by doTransform().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Transform an image using the Imagick PHP extension.

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

Definition at line 365 of file Bitmap.php.

References $result, $wgMaxAnimatedGifArea, $wgSharpenParameter, $wgSharpenReductionThreshold, extractPreRotationDimensions(), getImageArea(), getMediaTransformError(), getRotation(), ImageHandler\isAnimatedImage(), and wfDebug().

Referenced by doTransform().

Here is the call graph for this function:

Here is the caller graph for this function:


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