protected function autoOrient()
    {
        // apply EXIF orientation to pixel data
        switch ($this->originalImage->getImageOrientation()) {
            case \Imagick::ORIENTATION_BOTTOMRIGHT:
                $this->originalImage->rotateimage('#000', 180); // rotate 180 degrees
                break;
            case \Imagick::ORIENTATION_RIGHTTOP:
                $this->originalImage->rotateimage('#000', 90); // rotate 90 degrees CW
                break;
            case \Imagick::ORIENTATION_LEFTBOTTOM:
                $this->originalImage->rotateimage('#000', -90); // rotate 90 degrees CCW
                break;
        }

        // reset EXIF orientation
        $this->originalImage->setImageOrientation(\Imagick::ORIENTATION_TOPLEFT);
    }