ImageProc - Linux/Windows quick image processing designed for internal company use
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

38 lines
1.0 KiB

  1. <?php
  2. function autorotate(Imagick $image)
  3. {
  4. switch ($image->getImageOrientation()) {
  5. case Imagick::ORIENTATION_TOPLEFT:
  6. break;
  7. case Imagick::ORIENTATION_TOPRIGHT:
  8. $image->flopImage();
  9. break;
  10. case Imagick::ORIENTATION_BOTTOMRIGHT:
  11. $image->rotateImage("#000", 180);
  12. break;
  13. case Imagick::ORIENTATION_BOTTOMLEFT:
  14. $image->flopImage();
  15. $image->rotateImage("#000", 180);
  16. break;
  17. case Imagick::ORIENTATION_LEFTTOP:
  18. $image->flopImage();
  19. $image->rotateImage("#000", -90);
  20. break;
  21. case Imagick::ORIENTATION_RIGHTTOP:
  22. $image->rotateImage("#000", 90);
  23. break;
  24. case Imagick::ORIENTATION_RIGHTBOTTOM:
  25. $image->flopImage();
  26. $image->rotateImage("#000", 90);
  27. break;
  28. case Imagick::ORIENTATION_LEFTBOTTOM:
  29. $image->rotateImage("#000", -90);
  30. break;
  31. default: // Invalid orientation
  32. break;
  33. }
  34. $image->setImageOrientation(Imagick::ORIENTATION_TOPLEFT);
  35. return $image;
  36. }
  37. ?>