From de4d970d7725cd422cd7b57b298cb7a248aa1f10 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sat, 3 Jan 2015 22:02:24 +0000 Subject: [PATCH] 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 --- wp-includes/class-wp-image-editor-gd.php | 5 ++++- wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/wp-includes/class-wp-image-editor-gd.php b/wp-includes/class-wp-image-editor-gd.php index ddba1ff8bb..37598b2a5e 100644 --- a/wp-includes/class-wp-image-editor-gd.php +++ b/wp-includes/class-wp-image-editor-gd.php @@ -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(); diff --git a/wp-includes/version.php b/wp-includes/version.php index e6acd1f799..3158597e09 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.