Quickie experimental SVG rasterization hack: if using $wgImageMagick, will attempt...
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 4 Oct 2004 10:55:43 +0000 (10:55 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 4 Oct 2004 10:55:43 +0000 (10:55 +0000)
Incomplete so far:
* If you just ask for the image (or eg look at the image page) without a size, it tries a straight <img> 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

index e6fbb19..24c7896 100644 (file)
@@ -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;
        }
 
        /**