From: Rob Church Date: Sun, 19 Mar 2006 03:16:17 +0000 (+0000) Subject: Support a custom convert command for thumbnailing. See DefaultSettings.php and the... X-Git-Tag: 1.6.0~186 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/supprimer.php?a=commitdiff_plain;h=bff6b799b474b52a8150e83f382913107e04b581;p=lhc%2Fweb%2Fwiklou.git Support a custom convert command for thumbnailing. See DefaultSettings.php and the comments for $wgCustomConvertCommand, for more information. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index f151e54a71..344548cfe7 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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. diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 5338303c10..79b6f7f109 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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. diff --git a/includes/Image.php b/includes/Image.php index 70965263f6..96f8c5c568 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -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. #