MediaWiki
REL1_24
|
Handler for images that need to be transformed. More...
Public Member Functions | |
autoRotateEnabled () | |
Should we automatically rotate an image based on exif. | |
canRotate () | |
Returns whether the current scaler supports rotation. | |
doTransform ($image, $dstPath, $dstUrl, $params, $flags=0) | |
Create a thumbnail. | |
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) | |
Returns whether the file needs to be rendered. | |
normaliseParams ($image, &$params) | |
rotate ($file, $params) | |
Rotate a thumbnail. | |
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. | |
getScalerType ($dstPath, $checkDstPath=true) | |
Returns what sort of scaler type should be used. | |
getThumbnailSource ($file, $params) | |
Get the source file for the transform. | |
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. |
Handler for images that need to be transformed.
Definition at line 35 of file TransformationalImageHandler.php.
Should we automatically rotate an image based on exif.
Reimplemented in BitmapHandler.
Definition at line 563 of file TransformationalImageHandler.php.
Returns whether the current scaler supports rotation.
Reimplemented from MediaHandler.
Reimplemented in BitmapHandler.
Definition at line 552 of file TransformationalImageHandler.php.
Referenced by mustRender().
TransformationalImageHandler::doTransform | ( | $ | image, |
$ | dstPath, | ||
$ | dstUrl, | ||
$ | params, | ||
$ | flags = 0 |
||
) |
Create a thumbnail.
This sets up various parameters, and then calls a helper method based on $this->getScalerType in order to scale the image.
File | $image | |
string | $dstPath | |
string | $dstUrl | |
array | $params | |
int | $flags |
Reimplemented from MediaHandler.
Reimplemented in BitmapHandler_ClientOnly, and MockBitmapHandler.
Definition at line 128 of file TransformationalImageHandler.php.
References $flags, $params, array(), as, getClientScalingThumbnailImage(), getScalerType(), getThumbnailSource(), normaliseParams(), of, on, page, MediaHandler\removeBadFile(), text, transformCustom(), transformGd(), transformImageMagick(), transformImageMagickExt(), wfDebug(), wfDebugLog(), wfHostname(), wfMessage(), wfMkdirParents(), wfRunHooks(), and will.
TransformationalImageHandler::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.
string | $path | The file path |
bool | string | $scene | The scene specification, or false if there is none |
MWException |
Definition at line 456 of file TransformationalImageHandler.php.
References $path, and escapeMagickPath().
Referenced by BitmapHandler\rotate(), and BitmapHandler\transformImageMagick().
TransformationalImageHandler::escapeMagickOutput | ( | $ | path, |
$ | scene = false |
||
) |
Escape a string for ImageMagick's output filename.
See InterpretImageFilename() in magick/image.c.
string | $path | The file path |
bool | string | $scene | The scene specification, or false if there is none |
Definition at line 476 of file TransformationalImageHandler.php.
References $path, and escapeMagickPath().
Referenced by BitmapHandler\rotate(), and BitmapHandler\transformImageMagick().
TransformationalImageHandler::escapeMagickPath | ( | $ | path, |
$ | scene = false |
||
) | [protected] |
Armour a string against ImageMagick's GetPathComponent().
This is a helper function for escapeMagickInput() and escapeMagickOutput().
string | $path | The file path |
bool | string | $scene | The scene specification, or false if there is none |
MWException |
Definition at line 491 of file TransformationalImageHandler.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
string | $s |
Definition at line 426 of file TransformationalImageHandler.php.
References $s.
Referenced by BitmapHandler\transformImageMagick().
TransformationalImageHandler::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.
array | $params | Parameters as returned by normaliseParams |
int | $rotation | The rotation angle that will be applied |
Definition at line 102 of file TransformationalImageHandler.php.
References $params, and array().
Referenced by BitmapHandler\transformGd(), BitmapHandler\transformImageMagick(), and BitmapHandler\transformImageMagickExt().
TransformationalImageHandler::getClientScalingThumbnailImage | ( | $ | image, |
$ | scalerParams | ||
) | [protected] |
Get a ThumbnailImage that respresents an image that will be scaled client side.
File | $image | File associated with this thumbnail |
array | $scalerParams | Array with scaler params |
Definition at line 343 of file TransformationalImageHandler.php.
References $params, and array().
Referenced by MockBitmapHandler\doClientImage(), and doTransform().
TransformationalImageHandler::getMagickVersion | ( | ) | [protected] |
Retrieve the version of the installed ImageMagick You can use PHPs version_compare() to use this value Value is cached for one hour.
Definition at line 522 of file TransformationalImageHandler.php.
References $cache, $matches, $retval, $wgMemc, global, wfDebug(), wfEscapeShellArg(), and wfShellExec().
Referenced by BitmapHandler\transformImageMagick().
TransformationalImageHandler::getMediaTransformError | ( | $ | params, |
$ | errMsg | ||
) |
Get a MediaTransformError with error 'thumbnail_error'.
array | $params | Parameter array as passed to the transform* functions |
string | $errMsg | Error message |
Definition at line 401 of file TransformationalImageHandler.php.
References $params.
Referenced by BitmapHandler\transformCustom(), transformCustom(), BitmapHandler\transformGd(), transformGd(), BitmapHandler\transformImageMagick(), transformImageMagick(), BitmapHandler\transformImageMagickExt(), and transformImageMagickExt().
TransformationalImageHandler::getScalerType | ( | $ | dstPath, |
$ | checkDstPath = true |
||
) | [abstract, protected] |
Returns what sort of scaler type should be used.
Values can be one of client, im, custom, gd, imext, or an array of object, method-name to call that specific method.
If specifying a custom scaler command with array( Obj, method ), the method in question should take 2 parameters, a File object, and a $scalerParams array with various options (See doTransform for what is in $scalerParams). On error it should return a MediaTransformError object. On success it should return false, and simply make sure the thumbnail file is located at $scalerParams['dstPath'].
If there is a problem with the output path, it returns "client" to do client side scaling.
string | $dstPath | |
bool | $checkDstPath | Check that $dstPath is valid |
Reimplemented in XCFHandler, and BitmapHandler.
Referenced by doTransform(), and normaliseParams().
TransformationalImageHandler::getThumbnailSource | ( | $ | file, |
$ | params | ||
) | [protected] |
Get the source file for the transform.
$file | File |
$params | Array |
Definition at line 306 of file TransformationalImageHandler.php.
References $file, and $params.
Referenced by doTransform().
TransformationalImageHandler::mustRender | ( | $ | file | ) |
Returns whether the file needs to be rendered.
Returns true if the file requires rotation and we are able to rotate it.
File | $file |
Reimplemented from MediaHandler.
Reimplemented in TiffHandler, XCFHandler, and BmpHandler.
Definition at line 590 of file TransformationalImageHandler.php.
References $file, canRotate(), and MediaHandler\getRotation().
TransformationalImageHandler::normaliseParams | ( | $ | image, |
&$ | params | ||
) |
File | $image | |
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. |
Reimplemented from ImageHandler.
Reimplemented in BitmapHandler_ClientOnly, and JpegHandler.
Definition at line 43 of file TransformationalImageHandler.php.
References $params, array(), getScalerType(), global, and wfRunHooks().
Referenced by doTransform(), and BitmapScalingTest\testNormaliseParams().
TransformationalImageHandler::rotate | ( | $ | file, |
$ | params | ||
) |
Rotate a thumbnail.
This is a stub. See BitmapHandler::rotate.
File | $file | |
array | $params | Rotate parameters. 'rotation' clockwise rotation in degrees, allowed are multiples of 90 |
Reimplemented in BitmapHandler, and JpegHandler.
Definition at line 578 of file TransformationalImageHandler.php.
TransformationalImageHandler::transformCustom | ( | $ | image, |
$ | params | ||
) | [protected] |
Transform an image using a custom command.
This is a stub method. The real method is in BitmapHander.
Reimplemented in BitmapHandler.
Definition at line 390 of file TransformationalImageHandler.php.
References $params, and getMediaTransformError().
Referenced by doTransform().
TransformationalImageHandler::transformGd | ( | $ | image, |
$ | params | ||
) | [protected] |
Transform an image using the built in GD library.
This is a stub method. The real method is in BitmapHander.
Reimplemented in BitmapHandler.
Definition at line 416 of file TransformationalImageHandler.php.
References $params, and getMediaTransformError().
Referenced by doTransform().
TransformationalImageHandler::transformImageMagick | ( | $ | image, |
$ | params | ||
) | [protected] |
Transform an image using ImageMagick.
This is a stub method. The real method is in BitmapHander.
Reimplemented in BitmapHandler.
Definition at line 362 of file TransformationalImageHandler.php.
References $params, and getMediaTransformError().
Referenced by doTransform().
TransformationalImageHandler::transformImageMagickExt | ( | $ | image, |
$ | params | ||
) | [protected] |
Transform an image using the Imagick PHP extension.
This is a stub method. The real method is in BitmapHander.
Reimplemented in BitmapHandler.
Definition at line 376 of file TransformationalImageHandler.php.
References $params, and getMediaTransformError().
Referenced by doTransform().