r71546 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71545‎ | r71546 | r71547 >
Date:08:48, 24 August 2010
Author:tstarling
Status:ok
Tags:
Comment:
Fixes for new ImageMagick:
* (bug 24824) Support ImageMagick 6.5.6-2+ JPEG decoder size hint, to reduce memory usage when such an ImageMagick is used for scaling.
* Removed -size option since it doesn't act as a JPEG decoder size hint with recent ImageMagicks, and it may cause undesired behaviour in the future since it's documented to do something different now.
* Disable multithreaded behaviour in recent ImageMagick, to avoid a deadlock when a resource limit such as $wgMaxShellMemory is hit.
* Fixed some comments.

Replaces WMF live hack.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/media/Bitmap.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/media/Bitmap.php
@@ -120,12 +120,15 @@
121121 $scene = false;
122122 $animation_pre = '';
123123 $animation_post = '';
 124+ $decoderHint = '';
124125 if ( $mimeType == 'image/jpeg' ) {
125126 $quality = "-quality 80"; // 80%
126127 # Sharpening, see bug 6193
127128 if ( ( $physicalWidth + $physicalHeight ) / ( $srcWidth + $srcHeight ) < $wgSharpenReductionThreshold ) {
128129 $sharpen = "-sharpen " . wfEscapeShellArg( $wgSharpenParameter );
129130 }
 131+ // JPEG decoder hint to reduce memory, available since IM 6.5.6-2
 132+ $decoderHint = "-define jpeg:size={$physicalWidth}x{$physicalHeight}";
130133 } elseif ( $mimeType == 'image/png' ) {
131134 $quality = "-quality 95"; // zlib 9, adaptive filtering
132135 } elseif( $mimeType == 'image/gif' ) {
@@ -150,20 +153,18 @@
151154 $tempEnv = '';
152155 }
153156
154 - # Specify white background color, will be used for transparent images
155 - # in Internet Explorer/Windows instead of default black.
156 -
157 - # Note, we specify "-size {$physicalWidth}" and NOT "-size {$physicalWidth}x{$physicalHeight}".
158 - # It seems that ImageMagick has a bug wherein it produces thumbnails of
159 - # the wrong size in the second case.
160 -
161157 $cmd =
162158 $tempEnv .
 159+ // Use one thread only, to avoid deadlock bugs on OOM
 160+ 'OMP_NUM_THREADS=1 ' .
163161 wfEscapeShellArg( $wgImageMagickConvertCommand ) .
164 - " {$quality} -background white -size {$physicalWidth} ".
 162+ // Specify white background color, will be used for transparent images
 163+ // in Internet Explorer/Windows instead of default black.
 164+ " {$quality} -background white".
 165+ " {$decoderHint} " .
165166 wfEscapeShellArg( $this->escapeMagickInput( $srcPath, $scene ) ) .
166167 " {$animation_pre}" .
167 - // For the -resize option a "!" is needed to force exact size,
 168+ // For the -thumbnail option a "!" is needed to force exact size,
168169 // or ImageMagick may decide your ratio is wrong and slice off
169170 // a pixel.
170171 " -thumbnail " . wfEscapeShellArg( "{$physicalWidth}x{$physicalHeight}!" ) .
Index: trunk/phase3/RELEASE-NOTES
@@ -303,6 +303,10 @@
304304 a repository due to missing 'name' attribute from the API list=allimages
305305 * (bug 24898) MediaWiki uses /tmp even if a vHost-specific tempdir is set, also
306306 make wfTempDir() return a sane value for Windows on worst-case
 307+* (bug 24824) Support ImageMagick 6.5.6-2+ JPEG decoder size hint, to reduce
 308+ memory usage when such an ImageMagick is used for scaling.
 309+* Disable multithreaded behaviour in recent ImageMagick, to avoid a deadlock
 310+ when a resource limit such as $wgMaxShellMemory is hit.
307311
308312 === API changes in 1.17 ===
309313 * (bug 22738) Allow filtering by action type on query=logevent.

Follow-up revisions

RevisionCommit summaryAuthorDate
r71547MFT r71546: ImageMagick fixes to replace live hacks.tstarling08:50, 24 August 2010
r74821r71546 broke imagemagick usage in Windows, since cmd.exe takes the variable...platonides19:48, 15 October 2010

Status & tagging log