| Index: trunk/phase3/includes/Image.php |
| — | — | @@ -580,7 +580,7 @@ |
| 581 | 581 | |
| 582 | 582 | if (!$mime || $mime==='unknown' || $mime==='unknown/unknown') return false; |
| 583 | 583 | |
| 584 | | - #if it's SVG, check if ther's a converter enabled |
| | 584 | + #if it's SVG, check if there's a converter enabled |
| 585 | 585 | if ($mime === 'image/svg') { |
| 586 | 586 | global $wgSVGConverters, $wgSVGConverter; |
| 587 | 587 | |
| — | — | @@ -934,7 +934,11 @@ |
| 935 | 935 | return null; |
| 936 | 936 | } |
| 937 | 937 | |
| 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 ) { |
| 939 | 943 | # Don't make an image bigger than the source |
| 940 | 944 | $thumb = new ThumbnailImage( $this->getViewURL(), $this->getWidth(), $this->getHeight() ); |
| 941 | 945 | wfProfileOut( $fname ); |
| — | — | @@ -1007,12 +1011,14 @@ |
| 1008 | 1012 | if( isset( $wgSVGConverters[$wgSVGConverter] ) ) { |
| 1009 | 1013 | global $wgSVGConverterPath; |
| 1010 | 1014 | $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 ), |
| 1014 | 1019 | wfEscapeShellArg( $this->imagePath ), |
| 1015 | 1020 | wfEscapeShellArg( $thumbPath ) ), |
| 1016 | 1021 | $wgSVGConverters[$wgSVGConverter] ); |
| | 1022 | + wfDebug( "reallyRenderThumb SVG: $cmd\n" ); |
| 1017 | 1023 | $conv = shell_exec( $cmd ); |
| 1018 | 1024 | } else { |
| 1019 | 1025 | $conv = false; |
| — | — | @@ -1025,7 +1031,7 @@ |
| 1026 | 1032 | " -quality 85 -background white -size {$width}x{$height} ". |
| 1027 | 1033 | wfEscapeShellArg($this->imagePath) . " -resize {$width}x{$height} " . |
| 1028 | 1034 | wfEscapeShellArg($thumbPath); |
| 1029 | | - wfDebug("reallyRenderThumb: running ImageMagick: $cmd"); |
| | 1035 | + wfDebug("reallyRenderThumb: running ImageMagick: $cmd\n"); |
| 1030 | 1036 | $conv = shell_exec( $cmd ); |
| 1031 | 1037 | } else { |
| 1032 | 1038 | # Use PHP's builtin GD library functions. |
| Index: trunk/phase3/includes/DefaultSettings.php |
| — | — | @@ -1117,11 +1117,14 @@ |
| 1118 | 1118 | 'sodipodi' => '$path/sodipodi -z -w $width -f $input -e $output', |
| 1119 | 1119 | 'inkscape' => '$path/inkscape -z -w $width -f $input -e $output', |
| 1120 | 1120 | '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', |
| 1121 | 1122 | ); |
| 1122 | 1123 | /** Pick one of the above */ |
| 1123 | 1124 | $wgSVGConverter = 'ImageMagick'; |
| 1124 | 1125 | /** If not in the executable PATH, specify */ |
| 1125 | 1126 | $wgSVGConverterPath = ''; |
| | 1127 | +/** Don't scale a SVG larger than this unless its native size is larger */ |
| | 1128 | +$wgSVGMaxSize = 1024; |
| 1126 | 1129 | |
| 1127 | 1130 | /** Set $wgCommandLineMode if it's not set already, to avoid notices */ |
| 1128 | 1131 | if( !isset( $wgCommandLineMode ) ) { |
| Index: trunk/phase3/RELEASE-NOTES |
| — | — | @@ -88,6 +88,8 @@ |
| 89 | 89 | text loads or other fields mucking up XML export output |
| 90 | 90 | * Add UploadVerification hook for custom file upload validation/security checks |
| 91 | 91 | * (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 |
| 92 | 94 | |
| 93 | 95 | |
| 94 | 96 | === Caveats === |