Manual:$wgSVGConverters/de-formal

From Linux Web Expert

<translate> SVG</translate>: $wgSVGConverters
List of paths to Scalable Vector Graphics (SVG) converters.
<translate> Introduced in version:</translate>1.4.0
<translate> Removed in version:</translate><translate> still in use</translate>
<translate> Allowed values:</translate>(array) see below
<translate> Default value:</translate>see below

Details

Scalable Vector Graphics (SVG) may be uploaded as images. However, SVG support in browsers is patchy – in particular, Internet Explorer before version 9 could not understand the SVG format at all.

Therefore, it is necessary to convert SVG format images to PNG format as a fallback. An external program is required to perform this conversion.

This array contains a list of SVG conversion programs and the command line for each one. To select which one to use on your system, set $wgSVGConverter variable.

Default values

<td class="mw-version-versionbox" title="<translate nowrap> The latest stable version is <tvar name=1>1.41</tvar></translate>">
<translate> ≥</translate> 1.39
<translate> MediaWiki version:</translate>
$wgSVGConverters = [
	'ImageMagick' => '$path/convert -background "#ffffff00" -thumbnail $widthx$height\\! $input PNG:$output',
	'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-convert -w $width -h $height -o $output $input',
	'imgserv' => '$path/imgserv-wrapper -i svg -o png -w$width $input $output',
	'ImagickExt' => [ 'SvgHandler::rasterizeImagickExt', ],
];
<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.38</tvar> is unsupported version</translate>">
1.25 – 1.38
<translate> MediaWiki versions:</translate>
$wgSVGConverters = [
	'ImageMagick' =>
		'$path/convert -background "#ffffff00" -thumbnail $widthx$height\! $input PNG:$output',
	'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-convert -w $width -h $height -o $output $input',
	'imgserv' => '$path/imgserv-wrapper -i svg -o png -w$width $input $output',
	'ImagickExt' => [ 'SvgHandler::rasterizeImagickExt' ],
];
<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.24</tvar> is unsupported version</translate>">
1.23 – 1.24
<translate> MediaWiki versions:</translate>
$wgSVGConverters = array(
	'ImageMagick' => '$path/convert -background white -thumbnail $widthx$height\! $input PNG:$output',
	'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',
	'imgserv' => '$path/imgserv-wrapper -i svg -o png -w$width $input $output',
	'ImagickExt' => array( 'SvgHandler::rasterizeImagickExt' ),
);
<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.22</tvar> is unsupported version</translate>">
1.21 – 1.22
<translate> MediaWiki versions:</translate>
$wgSVGConverters = array(
	'ImageMagick' => '$path/convert -background white -thumbnail $widthx$height\! $input PNG:$output',
	'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',
	'imgserv' => '$path/imgserv-wrapper -i svg -o png -w$width $input $output',
	'ImagickExt' => array( 'SvgHandler::rasterizeImagickExt' ),
);
<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.20</tvar> is unsupported version</translate>">
1.18 – 1.20
<translate> MediaWiki versions:</translate>
$wgSVGConverters = array(
	'ImageMagick' => '$path/convert -background white -thumbnail $widthx$height\! $input PNG:$output',
	'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',
	'imgserv' => '$path/imgserv-wrapper -i svg -o png -w$width $input $output',
	'ImagickExt' => array( 'SvgHandler::rasterizeImagickExt' ),
	);
<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.17</tvar> is unsupported version</translate>">
1.14 – 1.17
<translate> MediaWiki versions:</translate>
$wgSVGConverters = array(
	'ImageMagick' => '$path/convert -background white -thumbnail $widthx$height\! $input PNG:$output',
	'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',
	'imgserv' => '$path/imgserv-wrapper -i svg -o png -w$width $input $output',
	);
<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.13</tvar> is unsupported version</translate>">
1.13
MediaWiki Version:

1.13

$wgSVGConverters = array(
	'ImageMagick' => '$path/convert -background white -geometry $width $input PNG:$output',
	'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',
	'imgserv' => '$path/imgserv-wrapper -i svg -o png -w$width $input $output',
	);
<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.12</tvar> is unsupported version</translate>">
1.10 – 1.12
<translate> MediaWiki versions:</translate>
$wgSVGConverters = array(
	'ImageMagick' => '$path/convert -background white -geometry $width $input PNG:$output',
	'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',
	);
<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.9</tvar> is unsupported version</translate>">
1.5 – 1.9
<translate> MediaWiki versions:</translate>
$wgSVGConverters = array(
	'ImageMagick' => '$path/convert -background white -geometry $width $input $output',
	'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',
	);
<td class="mw-version-versionbox" title="<translate nowrap> MediaWiki <tvar name=1>1.4</tvar> is unsupported version</translate>">
1.4
MediaWiki Version:
$wgSVGConverters = array(
	'ImageMagick' => '$path/convert -background white -geometry $width $input $output',
	'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',
	);

Usage

The following variables can be specified in the command line:

  • $path - the value of $wgSVGConverterPath , if set; otherwise $path/ (note the slash) will be stripped
  • $input - the path to the input SVG file
  • $output - the path where MediaWiki will look for the output PNG file
  • $width - the desired width
  • $height - the desired height
The exclamation mark (!)' is a meta-character in Unix shells and must be escaped with a backslash. In the code sample above, this can be seen in the command for ImageMagick. On Windows-family operating systems, the exclamation mark (!) is not a meta-character in the shell and does not need to be escaped.

Example

A fictitious example, which assumes that an executable named mysvg2png is on the system path:

$wgSVGConverters = [
	'mysvg2png' => '$path/mysvg2png -input $input -toFormat PNG -w $width -h $height -output $output'
];
$wgSVGConverter = 'mysvg2png';

Platform-specific notes

Windows

On Windows, where the executable path may contain spaces, you may need to quote the executable name. For example:

$wgSVGConverters = [
    'inkscape' => '"$path/Inkscape/inkscape" -z -w $width -f $input -e $output',
];

On Windows-family operating systems, the exclamation mark (!) is not a meta-character in the shell and does not need to be escaped.

Inkscape.exe does not accept command line arguments in the default release. You will need to download inkscapec.exe. Then set the $wgSVGConverters to the following.

$wgSVGConverters = [
    'inkscape' => 'inkscapec.exe --file=$input --export-png=$output --export-width=$width --without-gui',
];

The inkscapec.exe handles both long and short versions of the command-line.

On Windows-family operating systems, the exclamation mark (!) is not a meta-character in the shell and does not need to be escaped.

Linux

On some Linux installations (e.g. OpenSuSE 10.3, Debian, Ubuntu) rsvg is renamed (and might be packaged separately):

$wgSVGConverters = [ 'rsvg' => '/usr/bin/rsvg-convert -w $width -h $height -o $output $input' ];
$wgSVGConverter = 'rsvg' ;

If the Java executable is not in the path, it must be specified to use batik, or a "Thumbnail creation failed:" message will be displayed. For example:

$wgSVGConverters['batik'] = '/usr/local/bin/java -Djava.awt.headless=true -jar $path/batik-rasterizer.jar -w $width -d $output $input';
Exclamation mark (!)' is a meta character in Unix shells and must be escaped with a backslash.

OpenBSD and FreeBSD

On OpenBSD and FreeBSD installations rsvg was renamed to rsvg-convert:

$wgSVGConverterPath = "/usr/local/bin";
$wgSVGConverters = [ 'rsvg' => '$path/rsvg-convert -w $width -h $height -o $output $input' ];
$wgSVGConverter = 'rsvg' ;

See also