Move rotating under if ($outputWidth == 0 && $outputHeight == 0)...