r25088 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25087‎ | r25088 | r25089 >
Date:18:28, 23 August 2007
Author:brion
Status:old
Tags:
Comment:
* Resizing transparent GIF images with GD now retains transparency by skipping
resampling
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
@@ -157,7 +157,7 @@
158158 wfDebug( "$err\n" );
159159 return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight, $err );
160160 }
161 - list( $loader, /* $colorStyle */, $saveType ) = $typemap[$mimeType];
 161+ list( $loader, $colorStyle, $saveType ) = $typemap[$mimeType];
162162
163163 if( !function_exists( $loader ) ) {
164164 $err = "Incomplete GD library configuration: missing function $loader";
@@ -168,16 +168,25 @@
169169 $src_image = call_user_func( $loader, $srcPath );
170170 $dst_image = imagecreatetruecolor( $physicalWidth, $physicalHeight );
171171
172 - //PNG-24 Alpha Trans
173 - $background = imagecolorallocate($dst_image, 0, 0, 0); //Make $dst_image all black
174 - ImageColorTransparent($dst_image, $background); //Make $dst_image transparent
175 - imagealphablending($dst_image, false);
 172+ // Initialise the destination image to transparent instead of
 173+ // the default solid black, to support PNG and GIF transparency nicely
 174+ $background = imagecolorallocate( $dst_image, 0, 0, 0 );
 175+ imagecolortransparent( $dst_image, $background );
 176+ imagealphablending( $dst_image, false );
176177
177 - imagecopyresampled( $dst_image, $src_image,
178 - 0,0,0,0,
179 - $physicalWidth, $physicalHeight, imagesx( $src_image ), imagesy( $src_image ) );
 178+ if( $colorStyle == 'palette' ) {
 179+ // Don't resample for paletted GIF images.
 180+ // It may just uglify them, and completely breaks transparency.
 181+ imagecopyresized( $dst_image, $src_image,
 182+ 0,0,0,0,
 183+ $physicalWidth, $physicalHeight, imagesx( $src_image ), imagesy( $src_image ) );
 184+ } else {
 185+ imagecopyresampled( $dst_image, $src_image,
 186+ 0,0,0,0,
 187+ $physicalWidth, $physicalHeight, imagesx( $src_image ), imagesy( $src_image ) );
 188+ }
180189
181 - imagesavealpha($dst_image, true);
 190+ imagesavealpha( $dst_image, true );
182191
183192 call_user_func( $saveType, $dst_image, $dstPath );
184193 imagedestroy( $dst_image );
Index: trunk/phase3/RELEASE-NOTES
@@ -398,8 +398,8 @@
399399 * (bug 8737) Fix warnings caused by incorrect use of `/dev/null` when piping
400400 process error output under Windows
401401 * (bug 7890) Don't list redirects to special pages in Special:BrokenRedirects
402 -* (bug 10783) Resizing PNG-24 images causes all alpha channel transparency to be
403 - lost and transparent pixels to be turned black
 402+* (bug 10783) Resizing PNG-24 images with GD no longer causes all alpha
 403+ channel transparency to be lost and transparent pixels to be turned black
404404 * (bug 9339) General error pages were transforming messages and their parameters
405405 in the wrong order
406406 * (bug 9026) Incorrect heading numbering when viewing Special:Statistics with
@@ -407,7 +407,10 @@
408408 * Fixed invalid XHTML in Special:Upload
409409 * (bug 11013) Make sure dl() is available before attempting to use it to check
410410 available databases in installer
 411+* Resizing transparent GIF images with GD now retains transparency by skipping
 412+ resampling
411413
 414+
412415 == API changes since 1.10 ==
413416
414417 Full API documentation is available at http://www.mediawiki.org/wiki/API

Follow-up revisions

RevisionCommit summaryAuthorDate
r25109Merged revisions 25016-25108 via svnmerge from...david07:30, 24 August 2007

Status & tagging log