MediaWiki r13244 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r13243‎ | r13244 (on ViewVC)‎ | r13245 >
Date:03:16, 19 March 2006
Author:robchurch
Status:old
Tags:
Comment:
Support a custom convert command for thumbnailing. See DefaultSettings.php and the comments for $wgCustomConvertCommand, for more information.
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/Image.php
===================================================================
--- trunk/phase3/includes/Image.php	(revision 13243)
+++ trunk/phase3/includes/Image.php	(revision 13244)
@@ -1047,6 +1047,7 @@
 	function reallyRenderThumb( $thumbPath, $width, $height ) {
 		global $wgSVGConverters, $wgSVGConverter;
 		global $wgUseImageMagick, $wgImageMagickConvertCommand;
+		global $wgCustomConvertCommand;
 
 		$this->load();
 
@@ -1101,6 +1102,18 @@
 			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.
 			#
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 13243)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 13244)
@@ -1244,8 +1244,9 @@
 
 /**
  * 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 @@
 /** 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: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 13243)
+++ trunk/phase3/RELEASE-NOTES	(revision 13244)
@@ -116,6 +116,8 @@
 * 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.

Status & tagging log

  • 01:58, 13 October 2010 ^demon (Talk | contribs) changed the status of r13244 [removed: new added: old]
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox