MediaWiki r10961 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r10960‎ | r10961 (on ViewVC)‎ | r10962 >
Date:01:02, 10 September 2005
Author:vibber
Status:old
Tags:
Comment:
* Support SVG rendering with rsvg
* Cap arbitrary SVG renders to given image size or $wgSVGMaxSize pixels wide
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/Image.php
===================================================================
--- trunk/phase3/includes/Image.php	(revision 10960)
+++ trunk/phase3/includes/Image.php	(revision 10961)
@@ -580,7 +580,7 @@
 		
 		if (!$mime || $mime==='unknown' || $mime==='unknown/unknown') return false;
 		
-		#if it's SVG, check if ther's a converter enabled    
+		#if it's SVG, check if there's a converter enabled    
 		if ($mime === 'image/svg') {
 			global $wgSVGConverters, $wgSVGConverter;
 			
@@ -934,7 +934,11 @@
 			return null;
 		}
 
-		if( $width >= $this->width && !$this->mustRender() ) {
+		global $wgSVGMaxSize;
+		$maxsize = $this->mustRender()
+			? max( $this->width, $wgSVGMaxSize )
+			: $this->width - 1;
+		if( $width > $maxsize ) {
 			# Don't make an image bigger than the source
 			$thumb = new ThumbnailImage( $this->getViewURL(), $this->getWidth(), $this->getHeight() );
 			wfProfileOut( $fname );
@@ -1007,12 +1011,14 @@
 			if( isset( $wgSVGConverters[$wgSVGConverter] ) ) {
 				global $wgSVGConverterPath;
 				$cmd = str_replace(
-					array( '$path/', '$width', '$input', '$output' ),
-					array( $wgSVGConverterPath,
-						   $width,
+					array( '$path/', '$width', '$height', '$input', '$output' ),
+					array( $wgSVGConverterPath ? "$wgSVGConverterPath/" : "",
+						   intval( $width ),
+						   intval( $height ),
 						   wfEscapeShellArg( $this->imagePath ),
 						   wfEscapeShellArg( $thumbPath ) ),
 					$wgSVGConverters[$wgSVGConverter] );
+				wfDebug( "reallyRenderThumb SVG: $cmd\n" );
 				$conv = shell_exec( $cmd );
 			} else {
 				$conv = false;
@@ -1025,7 +1031,7 @@
 				" -quality 85 -background white -size {$width}x{$height} ".
 				wfEscapeShellArg($this->imagePath) . " -resize {$width}x{$height} " .
 				wfEscapeShellArg($thumbPath);				
-			wfDebug("reallyRenderThumb: running ImageMagick: $cmd");
+			wfDebug("reallyRenderThumb: running ImageMagick: $cmd\n");
 			$conv = shell_exec( $cmd );
 		} else {
 			# Use PHP's builtin GD library functions.
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 10960)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 10961)
@@ -1117,11 +1117,14 @@
 	'sodipodi' => '$path/sodipodi -z -w $width -f $input -e $output',
 	'inkscape' => '$path/inkscape -z -w $width -f $input -e $output',
 	'batik' => 'java -Djava.awt.headless=true -jar $path/batik-rasterizer.jar -w $width -d $output $input',
+	'rsvg' => '$path/rsvg -w$width -h$height $input $output',
 	);
 /** Pick one of the above */
 $wgSVGConverter = 'ImageMagick';
 /** If not in the executable PATH, specify */
 $wgSVGConverterPath = '';
+/** Don't scale a SVG larger than this unless its native size is larger */
+$wgSVGMaxSize = 1024;
 
 /** Set $wgCommandLineMode if it's not set already, to avoid notices */
 if( !isset( $wgCommandLineMode ) ) {
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 10960)
+++ trunk/phase3/RELEASE-NOTES	(revision 10961)
@@ -88,6 +88,8 @@
   text loads or other fields mucking up XML export output
 * Add UploadVerification hook for custom file upload validation/security checks
 * (bug 3063) Remove some hardcodings from Hebrew localisation
+* Support SVG rendering with rsvg
+* Cap arbitrary SVG renders to given image size or $wgSVGMaxSize pixels wide
 
 
 === Caveats ===

Status & tagging log

  • 01:58, 13 October 2010 ^demon (Talk | contribs) changed the status of r10961 [removed: new added: old]
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox