public function getPageCount() { $pages = Console::exec(self::getGhostscriptCli() . " -dNODISPLAY -q -c '(" . $this->path . ") (r) file runpdfbegin pdfpagecount = quit'", null, 120); $pages = trim($pages); if (!is_numeric($pages)) { throw new \Exception("Unable to get page-count of " . $this->path); } return $pages; }