WP_Image_Editor_Imagick::maybe_exif_rotate() WordPress Method

This method is used to check whether an image needs to be rotated based on EXIF data. It first checks if the image has any EXIF data. If it does, it then checks whether the image needs to be rotated. If it does, it then rotates the image.

WP_Image_Editor_Imagick::maybe_exif_rotate() #

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


Description

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


Top ↑

Return

(bool|WP_Error) True if the image was rotated. False if no EXIF data or if the image doesn't need rotation. WP_Error if error while rotating.


Top ↑

Source

File: wp-includes/class-wp-image-editor-imagick.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.' ) );
		}
	}


Top ↑

Changelog

Changelog
VersionDescription
5.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.