imagick.autorotate.inc in Imagick 7
File
effects/imagick.autorotate.inc
View source
<?php
function image_imagick_autorotate(stdClass $image, $data = array()) {
$orientation = $image->resource
->getImageOrientation();
switch ($orientation) {
case Imagick::ORIENTATION_BOTTOMRIGHT:
case Imagick::ORIENTATION_BOTTOMLEFT:
$image->resource
->rotateimage(new ImagickPixel(), 180);
break;
case Imagick::ORIENTATION_RIGHTTOP:
case Imagick::ORIENTATION_LEFTTOP:
$image->resource
->rotateimage(new ImagickPixel(), 90);
break;
case Imagick::ORIENTATION_LEFTBOTTOM:
case Imagick::ORIENTATION_RIGHTBOTTOM:
$image->resource
->rotateimage(new ImagickPixel(), -90);
break;
}
if (in_array($orientation, array(
Imagick::ORIENTATION_TOPRIGHT,
Imagick::ORIENTATION_BOTTOMLEFT,
Imagick::ORIENTATION_LEFTTOP,
Imagick::ORIENTATION_RIGHTBOTTOM,
))) {
$image->resource
->flopImage();
}
return $image->resource
->setImageOrientation(Imagick::ORIENTATION_TOPLEFT);
}
function imagick_autorotate($image, $data = array()) {
image_toolkit_invoke('autorotate', $image, $data);
}