From 92c483515026b73e2436440682e1b00f7bd574c9 Mon Sep 17 00:00:00 2001 From: westi Date: Thu, 20 Dec 2007 22:24:39 +0000 Subject: [PATCH] Preserve PNG transparency/alpha during thumbnail creation. Fixes #2805 props Libertus/Otto42. git-svn-id: http://svn.automattic.com/wordpress/trunk@6439 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/image.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 5b08eef024..7bcd38ee84 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -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