diff --git a/src/wp-includes/class-wp-image-editor-imagick.php b/src/wp-includes/class-wp-image-editor-imagick.php
index 8f9b43c..34dd539 100644
|
a
|
b
|
class WP_Image_Editor_Imagick extends WP_Image_Editor { |
| 549 | 549 | try { |
| 550 | 550 | $this->image->rotateImage( new ImagickPixel('none'), 360-$angle ); |
| 551 | 551 | |
| | 552 | // Normalise Exif orientation data so that display is consistent across devices. |
| | 553 | $this->image->setImageOrientation( Imagick::ORIENTATION_TOPLEFT ); |
| | 554 | |
| 552 | 555 | // Since this changes the dimensions of the image, update the size. |
| 553 | 556 | $result = $this->update_size(); |
| 554 | 557 | if ( is_wp_error( $result ) ) |
diff --git a/tests/phpunit/data/images/test-image-upside-down.jpg b/tests/phpunit/data/images/test-image-upside-down.jpg
new file mode 100644
index 0000000..74505cf
Binary files /dev/null and b/tests/phpunit/data/images/test-image-upside-down.jpg differ
diff --git a/tests/phpunit/tests/image/editor_imagick.php b/tests/phpunit/tests/image/editor_imagick.php
index c475201..e113b77 100644
|
a
|
b
|
class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase { |
| 542 | 542 | |
| 543 | 543 | $this->assertTrue( $result ); |
| 544 | 544 | } |
| | 545 | |
| | 546 | /** |
| | 547 | * Test resetting Exif orientation data on rotate |
| | 548 | * |
| | 549 | * @ticket 37140 |
| | 550 | */ |
| | 551 | public function test_remove_orientation_data_on_rotate() { |
| | 552 | $file = DIR_TESTDATA . "/images/test-image-upside-down.jpg"; |
| | 553 | $data = wp_read_image_metadata( $file ); |
| | 554 | |
| | 555 | // The orientation value 3 is equivalent to rotated upside down (180 degrees). |
| | 556 | $this->assertEquals( 3, intval( $data['orientation'] ), 'Orientation value read from does not match image file Exif data: ' . $file ); |
| | 557 | |
| | 558 | $temp_file = wp_tempnam( $file ); |
| | 559 | $image = wp_get_image_editor( $file ); |
| | 560 | |
| | 561 | // Test a value that would not lead back to 1, as WP is resetting the value to 1 manually. |
| | 562 | $image->rotate( 90 ); |
| | 563 | $ret = $image->save( $temp_file, 'image/jpeg' ); |
| | 564 | |
| | 565 | $data = wp_read_image_metadata( $ret['path'] ); |
| | 566 | |
| | 567 | // Make sure the image is no longer in The Upside Down Exif orientation. |
| | 568 | $this->assertEquals( 1, intval( $data['orientation'] ), 'Orientation Exif data was not updated after rotating image: ' . $file ); |
| | 569 | |
| | 570 | // Remove both the generated file ending in .tmp and tmp.jpg due to wp_tempnam(). |
| | 571 | unlink( $temp_file ); |
| | 572 | unlink( $ret['path'] ); |
| | 573 | } |
| | 574 | |
| 545 | 575 | } |