Make WordPress Core


Ignore:
Timestamp:
01/03/2015 10:01:54 PM (10 years ago)
Author:
wonderboymusic
Message:

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

Adds unit tests.

Props frankpw, voldemortensen.
Fixes #30596.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-image-editor-gd.php

    r30681 r31040  
    307307    public function rotate( $angle ) {
    308308        if ( function_exists('imagerotate') ) {
    309             $rotated = imagerotate( $this->image, $angle, 0 );
     309            $transparency = imagecolorallocatealpha( $this->image, 255, 255, 255, 127 );
     310            $rotated = imagerotate( $this->image, $angle, $transparency );
    310311
    311312            if ( is_resource( $rotated ) ) {
     313                imagealphablending( $rotated, true );
     314                imagesavealpha( $rotated, true );
    312315                imagedestroy( $this->image );
    313316                $this->image = $rotated;
Note: See TracChangeset for help on using the changeset viewer.