Ticket #24871: 24871.diff
File 24871.diff, 2.4 KB (added by , 10 years ago) |
---|
-
tests/phpunit/tests/image/editor_imagick.php
461 461 */ 462 462 public function test_image_preserves_alpha_on_resize() { 463 463 $file = DIR_TESTDATA . '/images/transparent.png'; 464 465 464 $editor = wp_get_image_editor( $file ); 466 465 467 466 $this->assertNotInstanceOf( 'WP_Error', $editor ); … … 472 471 473 472 $editor->save( $save_to_file ); 474 473 475 $this->assertImageAlphaAtPoint( $save_to_file, array( 0,0 ), 127 ); 474 $im = new Imagick( $save_to_file ); 475 $pixel = $im->getImagePixelColor( 0, 0 ); 476 $expected = $pixel->getColorValue(imagick::COLOR_ALPHA); 476 477 478 $this->assertImageAlphaAtPoint( $save_to_file, array( 0, 0 ), $expected ); 479 477 480 unlink( $save_to_file ); 478 481 } 479 482 … … 484 487 */ 485 488 public function test_image_preserves_alpha() { 486 489 $file = DIR_TESTDATA . '/images/transparent.png'; 487 488 490 $editor = wp_get_image_editor( $file ); 489 490 491 $this->assertNotInstanceOf( 'WP_Error', $editor ); 491 492 492 493 $editor->load(); 493 494 494 $save_to_file = tempnam( get_temp_dir(), '' ) . '.png'; 495 496 495 $editor->save( $save_to_file ); 497 496 498 $this->assertImageAlphaAtPoint( $save_to_file, array( 0,0 ), 127 ); 497 $im = new Imagick( $save_to_file ); 498 $pixel = $im->getImagePixelColor( 0, 0 ); 499 $expected = $pixel->getColorValue( imagick::COLOR_ALPHA ); 499 500 501 $this->assertImageAlphaAtPoint( $save_to_file, array( 0,0 ), $expected ); 502 500 503 unlink( $save_to_file ); 501 504 } 502 505 } -
tests/phpunit/tests/image/base.php
42 42 * @param array $point array(x,y) 43 43 * @param int $alpha 44 44 */ 45 protected function assertImageAlphaAtPoint( $image_path, $point, $alpha ) { 46 $im = imagecreatefrompng( $image_path ); 47 $rgb = imagecolorat( $im, $point[0], $point[1] ); 48 49 $colors = imagecolorsforindex( $im, $rgb ); 50 51 $this->assertEquals( $alpha, $colors['alpha'] ); 45 protected function assertImageAlphaAtPoint( $image_path, $point, $expected ) { 46 $im = new Imagick( $image_path ); 47 $pixel = $im->getImagePixelColor( $point[0], $point[1] ); 48 $color = $pixel->getColorValue(imagick::COLOR_ALPHA); 49 $this->assertEquals( $expected, $color ); 52 50 } 53 51 54 52 /**