Ticket #24871: 24871(1).diff
File 24871(1).diff, 3.6 KB (added by , 10 years ago) |
---|
-
tests/phpunit/tests/image/base.php
36 36 } 37 37 38 38 /** 39 * Helper assertion for testing alpha on images 39 * Helper assertion for testing alpha on images using GD library 40 40 * 41 41 * @param string $image_path 42 42 * @param array $point array(x,y) 43 43 * @param int $alpha 44 44 */ 45 protected function assertImageAlphaAtPoint ( $image_path, $point, $alpha ) {45 protected function assertImageAlphaAtPointGD( $image_path, $point, $alpha ) { 46 46 $im = imagecreatefrompng( $image_path ); 47 47 $rgb = imagecolorat( $im, $point[0], $point[1] ); 48 48 … … 52 52 } 53 53 54 54 /** 55 * Helper assertion for testing alpha on images using Imagick 56 * 57 * @param string $image_path 58 * @param array $point array(x,y) 59 * @param int $expected 60 */ 61 protected function assertImageAlphaAtPointImagick( $image_path, $point, $expected ) { 62 $im = new Imagick( $image_path ); 63 $pixel = $im->getImagePixelColor( $point[0], $point[1] ); 64 $color = $pixel->getColorValue( imagick::COLOR_ALPHA ); 65 $this->assertEquals( $expected, $color ); 66 } 67 68 /** 55 69 * Helper assertion to check actual image dimensions on disk 56 70 * 57 71 * @param string $filename Image filename. -
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 467 465 $this->assertNotInstanceOf( 'WP_Error', $editor ); 468 466 469 467 $editor->load(); … … 472 470 473 471 $editor->save( $save_to_file ); 474 472 475 $this->assertImageAlphaAtPoint( $save_to_file, array( 0,0 ), 127 ); 473 $im = new Imagick( $save_to_file ); 474 $pixel = $im->getImagePixelColor( 0, 0 ); 475 $expected = $pixel->getColorValue( imagick::COLOR_ALPHA ); 476 476 477 $this->assertImageAlphaAtPointImagick( $save_to_file, array( 0,0 ), $expected ); 478 477 479 unlink( $save_to_file ); 478 480 } 479 481 … … 484 486 */ 485 487 public function test_image_preserves_alpha() { 486 488 $file = DIR_TESTDATA . '/images/transparent.png'; 487 488 489 $editor = wp_get_image_editor( $file ); 489 490 490 $this->assertNotInstanceOf( 'WP_Error', $editor ); 491 491 492 492 $editor->load(); 493 494 493 $save_to_file = tempnam( get_temp_dir(), '' ) . '.png'; 495 496 494 $editor->save( $save_to_file ); 497 495 498 $this->assertImageAlphaAtPoint( $save_to_file, array( 0,0 ), 127 ); 496 $im = new Imagick( $save_to_file ); 497 $pixel = $im->getImagePixelColor( 0, 0 ); 498 $expected = $pixel->getColorValue( imagick::COLOR_ALPHA ); 499 499 500 $this->assertImageAlphaAtPointImagick( $save_to_file, array( 0,0 ), $expected ); 501 500 502 unlink( $save_to_file ); 501 503 } 502 504 } -
tests/phpunit/tests/image/editor_gd.php
472 472 473 473 $editor->save( $save_to_file ); 474 474 475 $this->assertImageAlphaAtPoint ( $save_to_file, array( 0,0 ), 127 );475 $this->assertImageAlphaAtPointGD( $save_to_file, array( 0,0 ), 127 ); 476 476 477 477 unlink( $save_to_file ); 478 478 } … … 495 495 496 496 $editor->save( $save_to_file ); 497 497 498 $this->assertImageAlphaAtPoint ( $save_to_file, array( 0,0 ), 127 );498 $this->assertImageAlphaAtPointGD( $save_to_file, array( 0,0 ), 127 ); 499 499 500 500 unlink( $save_to_file ); 501 501 }