summaryrefslogtreecommitdiff
path: root/includes/media/SVG.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2009-02-22 13:37:51 +0100
committerPierre Schmitz <pierre@archlinux.de>2009-02-22 13:37:51 +0100
commitb9b85843572bf283f48285001e276ba7e61b63f6 (patch)
tree4c6f4571552ada9ccfb4030481dcf77308f8b254 /includes/media/SVG.php
parentd9a20acc4e789cca747ad360d87ee3f3e7aa58c1 (diff)
updated to MediaWiki 1.14.0
Diffstat (limited to 'includes/media/SVG.php')
-rw-r--r--includes/media/SVG.php40
1 files changed, 28 insertions, 12 deletions
diff --git a/includes/media/SVG.php b/includes/media/SVG.php
index 2604e3b4..f0519e89 100644
--- a/includes/media/SVG.php
+++ b/includes/media/SVG.php
@@ -27,7 +27,6 @@ class SvgHandler extends ImageHandler {
if ( !parent::normaliseParams( $image, $params ) ) {
return false;
}
-
# Don't make an image bigger than wgMaxSVGSize
$params['physicalWidth'] = $params['width'];
$params['physicalHeight'] = $params['height'];
@@ -60,32 +59,49 @@ class SvgHandler extends ImageHandler {
return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight,
wfMsg( 'thumbnail_dest_directory' ) );
}
-
+
+ $status = $this->rasterize( $srcPath, $dstPath, $physicalWidth, $physicalHeight );
+ if( $status === true ) {
+ return new ThumbnailImage( $image, $dstUrl, $clientWidth, $clientHeight, $dstPath );
+ } else {
+ return $status; // MediaTransformError
+ }
+ }
+
+ /*
+ * Transform an SVG file to PNG
+ * This function can be called outside of thumbnail contexts
+ * @param string $srcPath
+ * @param string $dstPath
+ * @param string $width
+ * @param string $height
+ * @returns TRUE/MediaTransformError
+ */
+ public function rasterize( $srcPath, $dstPath, $width, $height ) {
+ global $wgSVGConverters, $wgSVGConverter, $wgSVGConverterPath;
$err = false;
- if( isset( $wgSVGConverters[$wgSVGConverter] ) ) {
+ if ( isset( $wgSVGConverters[$wgSVGConverter] ) ) {
$cmd = str_replace(
array( '$path/', '$width', '$height', '$input', '$output' ),
array( $wgSVGConverterPath ? wfEscapeShellArg( "$wgSVGConverterPath/" ) : "",
- intval( $physicalWidth ),
- intval( $physicalHeight ),
+ intval( $width ),
+ intval( $height ),
wfEscapeShellArg( $srcPath ),
wfEscapeShellArg( $dstPath ) ),
- $wgSVGConverters[$wgSVGConverter] ) . " 2>&1";
+ $wgSVGConverters[$wgSVGConverter]
+ ) . " 2>&1";
wfProfileIn( 'rsvg' );
wfDebug( __METHOD__.": $cmd\n" );
$err = wfShellExec( $cmd, $retval );
wfProfileOut( 'rsvg' );
}
-
$removed = $this->removeBadFile( $dstPath, $retval );
if ( $retval != 0 || $removed ) {
- wfDebugLog( 'thumbnail',
- sprintf( 'thumbnail failed on %s: error %d "%s" from "%s"',
+ wfDebugLog( 'thumbnail', sprintf( 'thumbnail failed on %s: error %d "%s" from "%s"',
wfHostname(), $retval, trim($err), $cmd ) );
- return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight, $err );
- } else {
- return new ThumbnailImage( $image, $dstUrl, $clientWidth, $clientHeight, $dstPath );
+ return new MediaTransformError( 'thumbnail_error', $width, $height, $err );
}
+ return true;
}
function getImageSize( $image, $path ) {