'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 ) ) {
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;
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 );
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;
" -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.