CakeFest 2025 Madrid: The Official CakePHP Conference

Voting

: min(two, four)?
(Example: nine)

The Note You're Voting On

mafo at mafo removethis dot sk
17 years ago
some cameras (most higher models) have position senzor (gyroskope?) and taking-position is wrote in EXIF, here is simple script for automatic rotating images

<?php
$exif
= exif_read_data($filename);
$ort = $exif['IFD0']['Orientation'];
switch(
$ort)
{
case
1: // nothing
break;

case
2: // horizontal flip
$image->flipImage($public,1);
break;

case
3: // 180 rotate left
$image->rotateImage($public,180);
break;

case
4: // vertical flip
$image->flipImage($public,2);
break;

case
5: // vertical flip + 90 rotate right
$image->flipImage($public, 2);
$image->rotateImage($public, -90);
break;

case
6: // 90 rotate right
$image->rotateImage($public, -90);
break;

case
7: // horizontal flip + 90 rotate right
$image->flipImage($public,1);
$image->rotateImage($public, -90);
break;

case
8: // 90 rotate left
$image->rotateImage($public, 90);
break;
}

?>

$image->rotateImage() is inspired by example of http://php.net/manual/en/function.imagerotate.php
$image->flipImage() is inspired by http://php.net/manual/en/function.imagecopy.php#42803 (thank you)

<< Back to user notes page

To Top