Minus Creative
By: a guest | Jul 20th, 2008 | Syntax:
PHP | Size: 1.04 KB | Hits: 92 | Expires: Never
/*
* A simple implementation for an 'EXIF' auto-rotate
* option in Image lib. Uses PHP's built-in EXIF
* reading capabilities. 'IFDO' is a small subset
* of the available EXIF data. It might be
* preferred to read all EXIF data instead, and
* then pass that information back to the user
* since it's already being read. Maybe they
* should be separated, and EXIF should be
* automagically called if 'EXIF' is passed
* to rotate.
*
* This is really simple and lacks basic checks, I know.
*/
/*
* Read the EXIF
*/
/*
* Auto-rotate based on provided EXIF
*/
switch($image->exif['Orientation']) {
case 1:
break;
case 2:
$image->flip(5);
break;
case 3:
$image->rotate(180);
break;
case 4:
$image->flip(6);
break;
case 5:
$image->rotate(90)->flip(6);
break;
case 6:
$image->rotate(90);
break;
case 7:
$image->rotate(90)->flip(5);
break;
case 8:
$image->rotate(-90);
break;
}