Support a custom convert command for thumbnailing. See DefaultSettings.php and the...
authorRob Church <robchurch@users.mediawiki.org>
Sun, 19 Mar 2006 03:16:17 +0000 (03:16 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Sun, 19 Mar 2006 03:16:17 +0000 (03:16 +0000)
RELEASE-NOTES
includes/DefaultSettings.php
includes/Image.php

index f151e54..344548c 100644 (file)
@@ -116,6 +116,8 @@ Images:
 * Don't delete thumbnails when refreshing exif metadata. This caused thumbs
   to vanish mysteriously from time to time for files that didn't have metadata.
 * (bug 4426) Add link to user_talk page on image pages
+* Support a custom convert command for thumbnailing. See DefaultSettings.php
+  and the comments for $wgCustomConvertCommand, for more information.
 
 Installer:
 * (bug 3782) Throw fatal installation warning if mbstring.func_overload on.
index 5338303..79b6f7f 100644 (file)
@@ -1244,8 +1244,9 @@ $wgUseImageResize         = false;
 
 /**
  * Resizing can be done using PHP's internal image libraries or using
- * ImageMagick. The later supports more file formats than PHP, which only
- * supports PNG, GIF, JPG, XBM and WBMP.
+ * ImageMagick or another third-party converter, e.g. GraphicMagick.
+ * These support more file formats than PHP, which only supports PNG,
+ * GIF, JPG, XBM and WBMP.
  *
  * Use Image Magick instead of PHP builtin functions.
  */
@@ -1253,6 +1254,17 @@ $wgUseImageMagick                = false;
 /** The convert command shipped with ImageMagick */
 $wgImageMagickConvertCommand    = '/usr/bin/convert';
 
+/**
+ * Use another resizing converter, e.g. GraphicMagick
+ * %s will be replaced with the source path, %d with the destination
+ * %w and %h will be replaced with the width and height
+ *
+ * An example is provided for GraphicMagick
+ * Leave as false to skip this
+ */
+#$wgCustomConvertCommand = "gm convert %s -resize %wx%h %d"
+$wgCustomConvertCommand = false;
+
 # Scalable Vector Graphics (SVG) may be uploaded as images.
 # Since SVG support is not yet standard in browsers, it is
 # necessary to rasterize SVGs to PNG as a fallback format.
index 7096526..96f8c5c 100644 (file)
@@ -1047,6 +1047,7 @@ class Image
        function reallyRenderThumb( $thumbPath, $width, $height ) {
                global $wgSVGConverters, $wgSVGConverter;
                global $wgUseImageMagick, $wgImageMagickConvertCommand;
+               global $wgCustomConvertCommand;
 
                $this->load();
 
@@ -1101,6 +1102,18 @@ class Image
                        wfProfileIn( 'convert' );
                        $err = wfShellExec( $cmd );
                        wfProfileOut( 'convert' );
+               } elseif( $wgCustomConvertCommand ) {
+                       # Use a custom convert command
+                       # Variables: %s %d %w %h
+                       $src = wfEscapeShellArg( $this->imagePath );
+                       $dst = wfEscapeShellArg( $thumbPath );
+                       $cmd = $wgCustomConvertCommand;
+                       $cmd = str_replace( '%s', $src, str_replace( '%d', $dst, $cmd ) ); # Filenames
+                       $cmd = str_replace( '%h', $height, str_replace( '%w', $width, $cmd ) ); # Size
+                       wfDebug( "reallyRenderThumb: Running custom convert command $cmd\n" );
+                       wfProfileIn( 'convert' );
+                       $err = wfShellExec( $cmd );
+                       wfProfileOut( 'convert' );
                } else {
                        # Use PHP's builtin GD library functions.
                        #