Preserve alpha transparency when rotating a PNG while GD is the active image editor.

Adds unit tests.

Props frankpw, voldemortensen.
Fixes #30596.

Built from https://develop.svn.wordpress.org/trunk@31040


git-svn-id: http://core.svn.wordpress.org/trunk@31021 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-01-03 22:02:24 +00:00
parent e678f9d051
commit de4d970d77
2 changed files with 5 additions and 2 deletions

View File

@ -306,9 +306,12 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
*/
public function rotate( $angle ) {
if ( function_exists('imagerotate') ) {
$rotated = imagerotate( $this->image, $angle, 0 );
$transparency = imagecolorallocatealpha( $this->image, 255, 255, 255, 127 );
$rotated = imagerotate( $this->image, $angle, $transparency );
if ( is_resource( $rotated ) ) {
imagealphablending( $rotated, true );
imagesavealpha( $rotated, true );
imagedestroy( $this->image );
$this->image = $rotated;
$this->update_size();

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-alpha-31039';
$wp_version = '4.2-alpha-31040';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.