From cecb985bee3bdd252e1b8dc0bd500b37cd52be01 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 16 May 2007 20:58:53 +0000 Subject: Aktualisierung auf MediaWiki 1.10.0 Plugins angepasst und verbessert kleine Korrekturen am Design --- includes/media/SVG.php | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 includes/media/SVG.php (limited to 'includes/media/SVG.php') diff --git a/includes/media/SVG.php b/includes/media/SVG.php new file mode 100644 index 00000000..5307e269 --- /dev/null +++ b/includes/media/SVG.php @@ -0,0 +1,97 @@ + $wgSVGMaxSize ) { + $srcWidth = $image->getWidth( $params['page'] ); + $srcHeight = $image->getHeight( $params['page'] ); + $params['physicalWidth'] = $wgSVGMaxSize; + $params['physicalHeight'] = Image::scaleHeight( $srcWidth, $srcHeight, $wgSVGMaxSize ); + } + return true; + } + + function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) { + global $wgSVGConverters, $wgSVGConverter, $wgSVGConverterPath; + + if ( !$this->normaliseParams( $image, $params ) ) { + return new TransformParameterError( $params ); + } + $clientWidth = $params['width']; + $clientHeight = $params['height']; + $physicalWidth = $params['physicalWidth']; + $physicalHeight = $params['physicalHeight']; + $srcWidth = $image->getWidth(); + $srcHeight = $image->getHeight(); + $srcPath = $image->getImagePath(); + + if ( $flags & self::TRANSFORM_LATER ) { + return new ThumbnailImage( $dstUrl, $clientWidth, $clientHeight, $dstPath ); + } + + if ( !wfMkdirParents( dirname( $dstPath ) ) ) { + return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight, + wfMsg( 'thumbnail_dest_directory' ) ); + } + + $err = false; + if( isset( $wgSVGConverters[$wgSVGConverter] ) ) { + $cmd = str_replace( + array( '$path/', '$width', '$height', '$input', '$output' ), + array( $wgSVGConverterPath ? wfEscapeShellArg( "$wgSVGConverterPath/" ) : "", + intval( $physicalWidth ), + intval( $physicalHeight ), + wfEscapeShellArg( $srcPath ), + wfEscapeShellArg( $dstPath ) ), + $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"', + wfHostname(), $retval, trim($err), $cmd ) ); + return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight, $err ); + } else { + return new ThumbnailImage( $dstUrl, $clientWidth, $clientHeight, $dstPath ); + } + } + + function getImageSize( $image, $path ) { + return wfGetSVGsize( $path ); + } + + function getThumbType( $ext, $mime ) { + return array( 'png', 'image/png' ); + } +} +?> -- cgit v1.2.2