From dddff772d13585bfc0f06c89c23a29e48033f2a2 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 27 Feb 2006 00:48:02 +0000 Subject: [PATCH] * (bug 5086) Force image resize dimensions on ImageMagick, as for instance "-resize 100x35!"; some thumbs were off due to differences in rounding and would be generated smaller than expected. --- RELEASE-NOTES | 4 ++++ includes/Image.php | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b8ce1a7005..87f2b8880d 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -663,6 +663,10 @@ fully support the editing toolbar, but was found to be too confusing. broke use of legitimate multiple whitespace characters in bracketed link. * (bug 4838) Add relative oldids (prev, next, cur) for raw pages Patch by Lupin +* (bug 5086) Force image resize dimensions on ImageMagick, as for instance + "-resize 100x35!"; some thumbs were off due to differences in rounding and + would be generated smaller than expected. + === Caveats === diff --git a/includes/Image.php b/includes/Image.php index 96e892fc2f..309a1d7dcf 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -1095,7 +1095,12 @@ class Image $cmd = wfEscapeShellArg($wgImageMagickConvertCommand) . " {$quality} -background white -size {$width} ". - wfEscapeShellArg($this->imagePath) . " -resize {$width}x{$height} -depth 8 " . + wfEscapeShellArg($this->imagePath) . + // For the -resize option a "!" is needed to force exact size, + // or ImageMagick may decide your ratio is wrong and slice off + // a pixel. + " -resize " . wfEscapeShellArg( "{$width}x{$height}!" ) . + " -depth 8 " . wfEscapeShellArg($thumbPath) . " 2>&1"; wfDebug("reallyRenderThumb: running ImageMagick: $cmd\n"); wfProfileIn( 'convert' ); -- 2.20.1