From b887b260a613ba40669a500d51bf04384cb54ac0 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 4 Oct 2004 10:55:43 +0000 Subject: [PATCH] Quickie experimental SVG rasterization hack: if using $wgImageMagick, will attempt to create thumbnails of SVG images as PNG. Incomplete so far: * If you just ask for the image (or eg look at the image page) without a size, it tries a straight with no rasterization still * ImageMagick may not be the best renderer. * It doesn't know the 'real' size of aspect ratio of the image. --- includes/Image.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/includes/Image.php b/includes/Image.php index e6fbb19ebb..24c7896293 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -54,6 +54,9 @@ class Image } $this->url = $this->wfImageUrl( $name ); + + $n = strrpos( $name, '.' ); + $this->extension = strtolower( $n ? substr( $name, $n + 1 ) : '' ); if ( $this->fileExists = file_exists( $this->imagePath ) ) // Sic!, "=" is intended { @@ -68,6 +71,10 @@ class Image } else { $this->bits = 0; } + } elseif( $this->extension == 'svg' ) { + $this->width = 512; + $this->height = 512; + $this->type = 'svg'; } } $this->historyLine = 0; @@ -234,7 +241,12 @@ class Image * @access private */ function thumbName( $width ) { - return $width."px-".$this->name; + $thumb = $width."px-".$this->name; + if( $this->extension == 'svg' ) { + # Rasterize SVG vector images to PNG + $thumb .= '.png'; + } + return $thumb; } /** -- 2.20.1