A package for dealing with exif image orientation

dev-master 2014-07-01 19:59 UTC

This package is not auto-updated.

Last update: 2024-06-18 00:17:30 UTC


EXIF Based Auto Rotation

This is a simple class that allows you to auto-rotate your images based on EXIF data imbedded in JPG and TIFF images.


Add "rtablada/exif": "dev-master" to your composer.json file.


Using this rotator takes a file path, SPLFileInfo instance, or Symfony\Request\UploadedFile along with an instance of Imagine (here we use GD). Then call rotate and you will be returned an auto-rotated image based on the EXIF data if any is present.

$imagine = new \Imagine\GD\Imagine;
$rotator = new \Rtablada\Exif\ExifRotator($pathToFile, $imagine);

$output = $resizer->rotate();

Use with Stapler

This was originally built for use within a Laravel project using Stapler. Using this rotator with Stapler is quite simple when defining your styles:

$this->hasAttachedFile('avatar', [
	'styles' => [
		'medium' => '300x300',
		'thumb' => function($file, $imagine) {
			$resizer = \Rtablada\Images\ResizeAndPad($file, $imagine);
			return $resizer->rotate();


If you would like to quickly rotate an image you can use makeAndRotate which skips the step of having to instantiate the rotator:

\Rtablada\Images\ResizeAndPad::makeAndRotate($file, $imagine)->save($output);