public function rotateJpg(&$that) { $this->parentInstance = $that; // Test if exif is installed if (!is_callable('exif_read_data')) { return $that; } // Exif couldn't do it's thing. Suppressing errors on it cause it // does a non-exception error if it can't read the image. $exif = @exif_read_data($this->parentInstance->getFilename()); // There is no orientation data, so exit if (empty($exif['Orientation'])) { return $that; } // Act on orientation info switch ($exif['Orientation']) { case 1: // nothing break; case 2: //code here break; case 3: // 180 rotate left $this->parentInstance->rotateImageNDegrees(180); break; case 4: // vertical flip // break; case 5: // vertical flip + 90 rotate right // break; case 6: // 90 rotate right $this->parentInstance->rotateImageNDegrees(-90); break; case 7: // horizontal flip + 90 rotate right // break; case 8: // 90 rotate left $this->parentInstance->rotateImageNDegrees(90); break; } return $that; }
public function rotateJpg(&$that) { $this->parentInstance = $that; $exif = exif_read_data($this->parentInstance->getFilename()); switch ($exif['Orientation']) { case 1: // nothing break; case 2: //code here break; case 3: // 180 rotate left $this->parentInstance->rotateImageNDegrees(180); break; case 4: // vertical flip // break; case 5: // vertical flip + 90 rotate right // break; case 6: // 90 rotate right $this->parentInstance->rotateImageNDegrees(-90); break; case 7: // horizontal flip + 90 rotate right // break; case 8: // 90 rotate left $this->parentInstance->rotateImageNDegrees(90); break; } return $that; }