Preserve PNG transparency/alpha during thumbnail creation. Fixes #2805 props Libertus/Otto42.
git-svn-id: https://develop.svn.wordpress.org/trunk@6439 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
afd0b9a623
commit
6a0ae6a9ed
@ -33,6 +33,13 @@ function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) {
|
||||
list($image_new_width, $image_new_height) = wp_shrink_dimensions( $sourceImageWidth, $sourceImageHeight, $max_side, $max_side);
|
||||
|
||||
$thumbnail = imagecreatetruecolor( $image_new_width, $image_new_height);
|
||||
|
||||
// preserve PNG transparency
|
||||
if( IMAGETYPE_PNG == $sourceImageType && function_exists( 'imagealphablending' ) && function_exists( 'imagesavealpha' )) {
|
||||
imagealphablending($thumbnail, false);
|
||||
imagesavealpha($thumbnail,true);
|
||||
}
|
||||
|
||||
@ imagecopyresampled( $thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $sourceImageWidth, $sourceImageHeight );
|
||||
|
||||
imagedestroy( $image ); // Free up memory
|
||||
|
Loading…
Reference in New Issue
Block a user