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
@@ -580,7 +580,7 @@
581581
582582 if (!$mime || $mime==='unknown' || $mime==='unknown/unknown') return false;
583583
584 - #if it's SVG, check if ther's a converter enabled
 584+ #if it's SVG, check if there's a converter enabled
585585 if ($mime === 'image/svg') {
586586 global $wgSVGConverters, $wgSVGConverter;
587587
@@ -934,7 +934,11 @@
935935 return null;
936936 }
937937
938 - if( $width >= $this->width && !$this->mustRender() ) {
 938+ global $wgSVGMaxSize;
 939+ $maxsize = $this->mustRender()
 940+ ? max( $this->width, $wgSVGMaxSize )
 941+ : $this->width - 1;
 942+ if( $width > $maxsize ) {
939943 # Don't make an image bigger than the source
940944 $thumb = new ThumbnailImage( $this->getViewURL(), $this->getWidth(), $this->getHeight() );
941945 wfProfileOut( $fname );
@@ -1007,12 +1011,14 @@
10081012 if( isset( $wgSVGConverters[$wgSVGConverter] ) ) {
10091013 global $wgSVGConverterPath;
10101014 $cmd = str_replace(
1011 - array( '$path/', '$width', '$input', '$output' ),
1012 - array( $wgSVGConverterPath,
1013 - $width,
 1015+ array( '$path/', '$width', '$height', '$input', '$output' ),
 1016+ array( $wgSVGConverterPath ? "$wgSVGConverterPath/" : "",
 1017+ intval( $width ),
 1018+ intval( $height ),
10141019 wfEscapeShellArg( $this->imagePath ),
10151020 wfEscapeShellArg( $thumbPath ) ),
10161021 $wgSVGConverters[$wgSVGConverter] );
 1022+ wfDebug( "reallyRenderThumb SVG: $cmd\n" );
10171023 $conv = shell_exec( $cmd );
10181024 } else {
10191025 $conv = false;
@@ -1025,7 +1031,7 @@
10261032 " -quality 85 -background white -size {$width}x{$height} ".
10271033 wfEscapeShellArg($this->imagePath) . " -resize {$width}x{$height} " .
10281034 wfEscapeShellArg($thumbPath);
1029 - wfDebug("reallyRenderThumb: running ImageMagick: $cmd");
 1035+ wfDebug("reallyRenderThumb: running ImageMagick: $cmd\n");
10301036 $conv = shell_exec( $cmd );
10311037 } else {
10321038 # Use PHP's builtin GD library functions.
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1117,11 +1117,14 @@
11181118 'sodipodi' => '$path/sodipodi -z -w $width -f $input -e $output',
11191119 'inkscape' => '$path/inkscape -z -w $width -f $input -e $output',
11201120 'batik' => 'java -Djava.awt.headless=true -jar $path/batik-rasterizer.jar -w $width -d $output $input',
 1121+ 'rsvg' => '$path/rsvg -w$width -h$height $input $output',
11211122 );
11221123 /** Pick one of the above */
11231124 $wgSVGConverter = 'ImageMagick';
11241125 /** If not in the executable PATH, specify */
11251126 $wgSVGConverterPath = '';
 1127+/** Don't scale a SVG larger than this unless its native size is larger */
 1128+$wgSVGMaxSize = 1024;
11261129
11271130 /** Set $wgCommandLineMode if it's not set already, to avoid notices */
11281131 if( !isset( $wgCommandLineMode ) ) {
Index: trunk/phase3/RELEASE-NOTES
@@ -88,6 +88,8 @@
8989 text loads or other fields mucking up XML export output
9090 * Add UploadVerification hook for custom file upload validation/security checks
9191 * (bug 3063) Remove some hardcodings from Hebrew localisation
 92+* Support SVG rendering with rsvg
 93+* Cap arbitrary SVG renders to given image size or $wgSVGMaxSize pixels wide
9294
9395
9496 === Caveats ===

Status & tagging log

  • 01:58, 13 October 2010 ^demon (talk | contribs) changed the status of r10961 [removed: new added: old]