Index: trunk/phase3/includes/media/Bitmap.php |
— | — | @@ -157,7 +157,7 @@ |
158 | 158 | wfDebug( "$err\n" ); |
159 | 159 | return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight, $err ); |
160 | 160 | } |
161 | | - list( $loader, /* $colorStyle */, $saveType ) = $typemap[$mimeType]; |
| 161 | + list( $loader, $colorStyle, $saveType ) = $typemap[$mimeType]; |
162 | 162 | |
163 | 163 | if( !function_exists( $loader ) ) { |
164 | 164 | $err = "Incomplete GD library configuration: missing function $loader"; |
— | — | @@ -168,16 +168,25 @@ |
169 | 169 | $src_image = call_user_func( $loader, $srcPath ); |
170 | 170 | $dst_image = imagecreatetruecolor( $physicalWidth, $physicalHeight ); |
171 | 171 | |
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 ); |
176 | 177 | |
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 | + } |
180 | 189 | |
181 | | - imagesavealpha($dst_image, true); |
| 190 | + imagesavealpha( $dst_image, true ); |
182 | 191 | |
183 | 192 | call_user_func( $saveType, $dst_image, $dstPath ); |
184 | 193 | imagedestroy( $dst_image ); |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -398,8 +398,8 @@ |
399 | 399 | * (bug 8737) Fix warnings caused by incorrect use of `/dev/null` when piping |
400 | 400 | process error output under Windows |
401 | 401 | * (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 |
404 | 404 | * (bug 9339) General error pages were transforming messages and their parameters |
405 | 405 | in the wrong order |
406 | 406 | * (bug 9026) Incorrect heading numbering when viewing Special:Statistics with |
— | — | @@ -407,7 +407,10 @@ |
408 | 408 | * Fixed invalid XHTML in Special:Upload |
409 | 409 | * (bug 11013) Make sure dl() is available before attempting to use it to check |
410 | 410 | available databases in installer |
| 411 | +* Resizing transparent GIF images with GD now retains transparency by skipping |
| 412 | + resampling |
411 | 413 | |
| 414 | + |
412 | 415 | == API changes since 1.10 == |
413 | 416 | |
414 | 417 | Full API documentation is available at http://www.mediawiki.org/wiki/API |