Media: Respect EXIF Rotations.

Previously, the logic to determine EXIF rotation information was not providing the correct rotation. This patch respects the information properly by swapping some of the `flip()` logic on certain rotations.

Props tbember, SergeyBiryukov, costdev, mikeschroder, adamsilverstein.
Fixes #54937.


git-svn-id: https://develop.svn.wordpress.org/trunk@54265 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Anthony Burchell 2022-09-20 16:57:15 +00:00
parent 55bdc301e2
commit d013b20c32

View File

@ -512,7 +512,7 @@ abstract class WP_Image_Editor {
switch ( $orientation ) {
case 2:
// Flip horizontally.
$result = $this->flip( true, false );
$result = $this->flip( false, true );
break;
case 3:
// Rotate 180 degrees or flip horizontally and vertically.
@ -521,14 +521,14 @@ abstract class WP_Image_Editor {
break;
case 4:
// Flip vertically.
$result = $this->flip( false, true );
$result = $this->flip( true, false );
break;
case 5:
// Rotate 90 degrees counter-clockwise and flip vertically.
$result = $this->rotate( 90 );
if ( ! is_wp_error( $result ) ) {
$result = $this->flip( false, true );
$result = $this->flip( true, false );
}
break;
@ -541,7 +541,7 @@ abstract class WP_Image_Editor {
$result = $this->rotate( 90 );
if ( ! is_wp_error( $result ) ) {
$result = $this->flip( true, false );
$result = $this->flip( false, true );
}
break;