I've noticed that the script doesn't work on large PDF files. I have one in particular that's about 28MB and about 900 pages. When I execute the refreshImageMetadata.php script, it just hanged and never finished.
I'm running MW 1.31.1 on IIS 8.5, PHP 7.1, Windows Server 2012 R2. Not sure if the $wgMaxShellMemory and $wgMaxShellFileSize works in Windows environment, but I've set both to about 2GB.
The script works on smaller PDF files and I was able to use rebuildImages.php to create thumbnails, so it's not an issue with permissions or ImageMagick/Ghostscript/Pdfhandler/pdfinfo/pdftotext.