static function imageAdjustOrientation($path)
	{
		// read image
		$image = new \imagick();
		if ( !$image->readImage($path) )
			return FALSE;
		
		
		// read exif orientation
		$orientation = $image->getImageOrientation(); 
		$rotated = false;

		switch($orientation)
		{ 
			case \imagick::ORIENTATION_BOTTOMRIGHT: 
				$image->rotateimage("#000", 180); // rotate 180 degrees 
				$rotated = true;
			break; 

			case \imagick::ORIENTATION_RIGHTTOP: 
				$image->rotateimage("#000", 90); // rotate 90 degrees CW 
				$rotated = true;
			break; 

			case \imagick::ORIENTATION_LEFTBOTTOM: 
				$image->rotateimage("#000", -90); // rotate 90 degrees CCW 
				$rotated = true;
			break; 
		} 

		// Now that it's auto-rotated, make sure the EXIF data is correct in case the EXIF gets saved with the image! 
		$image->setImageOrientation(\imagick::ORIENTATION_TOPLEFT); 
		
		
		if ( $rotated )
		{
			$image->setImageCompressionQuality(90);
			$image->writeImage($path); 
		}

		
		return TRUE;
	}
static function imageAdjustOrientation($path)
	{
		// read image
		$image = new \imagick();
		if ( !$image->readImage($path) )
			return FALSE;
		
		
		// read exif orientation
		$orientation = $image->getImageOrientation(); 
		$rotated = false;

		switch($orientation)
		{ 
			case \imagick::ORIENTATION_BOTTOMRIGHT: 
				$image->rotateimage("#000", 180); // rotate 180 degrees 
				$rotated = true;
			break; 

			case \imagick::ORIENTATION_RIGHTTOP: 
				$image->rotateimage("#000", 90); // rotate 90 degrees CW 
				$rotated = true;
			break; 

			case \imagick::ORIENTATION_LEFTBOTTOM: 
				$image->rotateimage("#000", -90); // rotate 90 degrees CCW 
				$rotated = true;
			break; 
		} 

		// Now that it's auto-rotated, make sure the EXIF data is correct in case the EXIF gets saved with the image! 
		$image->setImageOrientation(\imagick::ORIENTATION_TOPLEFT); 
		
		
		if ( $rotated )
		{
			$image->setImageCompressionQuality(90);
			$image->writeImage($path); 
		}

		
		return TRUE;
	}
static function imageAdjustOrientation ( $ path ) { // read image $ image = new \ imagick ( ) ; if ( ! $ image -> readImage ( $ path ) ) return FALSE ; // read exif orientation $ orientation = $ image -> getImageOrientation ( ) ; $ rotated = false ; switch ( $ orientation ) { case \ imagick :: ORIENTATION_BOTTOMRIGHT : $ image -> rotateimage ( "#000" , 180 ) ; // rotate 180 degrees  $ rotated = true ; break ; case \ imagick :: ORIENTATION_RIGHTTOP : $ image -> rotateimage ( "#000" , 90 ) ; // rotate 90 degrees CW  $ rotated = true ; break ; case \ imagick :: ORIENTATION_LEFTBOTTOM : $ image -> rotateimage ( "#000" , - 90 ) ; // rotate 90 degrees CCW  $ rotated = true ; break ; } // Now that it's auto-rotated, make sure the EXIF data is correct in case the EXIF gets saved with the image!  $ image -> setImageOrientation ( \ imagick :: ORIENTATION_TOPLEFT ) ; if ( $ rotated ) { $ image -> setImageCompressionQuality ( 90 ) ; $ image -> writeImage ( $ path ) ; } return TRUE ; }
If exif data indicates a rotated image, we apply the transformation to the image and set back orientation to normal

@param string $path Path to image
@return bool
If exif data indicates a rotated image we apply the transformation to the image and set back orientation to normal