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/tests/phpunit/tests/image/editor_gd.php

    r30660 r31040  
    500500        unlink( $save_to_file );
    501501    }
     502
     503    /**
     504     *
     505     * @ticket 30596
     506     */
     507    public function test_image_preserves_alpha_on_rotate() {
     508        $file = DIR_TESTDATA . '/images/transparent.png';
     509
     510        $image = imagecreatefrompng( $file );
     511        $rgb = imagecolorat( $image, 0, 0 );
     512        $expected = imagecolorsforindex( $image, $rgb );
     513
     514        $editor = new WP_Image_Editor_GD( $file );
     515                $this->assertNotInstanceOf( 'WP_Error', $editor );
     516                $editor->load();
     517                $editor->rotate( 180 );
     518                $save_to_file = tempnam( get_temp_dir(), '' ) . '.png';
     519
     520                $editor->save( $save_to_file );
     521
     522                $this->assertImageAlphaAtPointGD( $save_to_file, array( 0,0 ), $expected['alpha'] );
     523                unlink( $save_to_file );
     524
     525    }
    502526}
Note: See TracChangeset for help on using the changeset viewer.