imagemagick really did end up being too slow on PDFs with hundreds of pages, so I have FPDI a go and it seems quick and accurate so far. I used it with tcpdf since I am already using that, rather than FPDF, which is the default. Don't forget that you will also need FPDF_TPL. You can get both from here:
http://www.setasign.de/products/pdf-.../fpdi/fpdi.php
require_once('../../tcpdf/tcpdf.php');
require_once('../../fpdi/fpdi.php');
$pdf =& new FPDI();
$pagecount = $pdf->setSourceFile($filepath);
return $pagecount;