Title: WP_Image_Editor_Imagick::maybe_exif_rotate
Published: November 12, 2019
Last modified: August 20, 2026

---

# WP_Image_Editor_Imagick::maybe_exif_rotate(): bool|󠀁[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)󠁿

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/maybe_exif_rotate/?output_format=md#description)
 * [Return](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/maybe_exif_rotate/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/maybe_exif_rotate/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/maybe_exif_rotate/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/maybe_exif_rotate/?output_format=md#changelog)

Check if a JPEG image has EXIF Orientation tag and rotate it if needed.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/maybe_exif_rotate/?output_format=md#description)󠁿

As ImageMagick copies the EXIF data to the flipped/rotated image, proceed only if
EXIF Orientation can be reset afterwards.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/maybe_exif_rotate/?output_format=md#return)󠁿

 bool|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/) True
if the image was rotated. False if no EXIF data or if the image doesn’t need rotation.

[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/) if error
while rotating.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/maybe_exif_rotate/?output_format=md#source)󠁿

    ```php
    public function maybe_exif_rotate() {
    	if ( is_callable( array( $this->image, 'setImageOrientation' ) ) && defined( 'Imagick::ORIENTATION_TOPLEFT' ) ) {
    		return parent::maybe_exif_rotate();
    	} else {
    		return new WP_Error( 'write_exif_error', __( 'The image cannot be rotated because the embedded meta data cannot be updated.' ) );
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-image-editor-imagick.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-image-editor-imagick.php#L1040)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-image-editor-imagick.php#L1040-L1046)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/maybe_exif_rotate/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Image_Editor::maybe_exif_rotate()](https://developer.wordpress.org/reference/classes/wp_image_editor/maybe_exif_rotate/)`wp-includes/class-wp-image-editor.php` |

Check if a JPEG image has EXIF Orientation tag and rotate it if needed.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [WP_Error::__construct()](https://developer.wordpress.org/reference/classes/wp_error/__construct/)`wp-includes/class-wp-error.php` |

Initializes the error.

  |

[Show 1 more](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/maybe_exif_rotate/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/maybe_exif_rotate/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/maybe_exif_rotate/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.3.0](https://developer.wordpress.org/reference/since/5.3.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_image_editor_imagick%2Fmaybe_exif_rotate%2F)
before being able to contribute a note or feedback.