Magick.NET
Magick.NET copied to clipboard
pageCount fails in newer versions of ghostscript
Magick.NET version
14.5.0
Environment (Operating system, version and so on)
Ubuntu 24.04 (docker)
Description
When using pdfInfo.PageCount to get the number of pages, the system executes something like
'gs' -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT --permit-file-read='/tmp/file.pdf' -sPDFPassword='' -c '(/tmp/file.pdf) (r) file runpdfbegin pdfpagecount = quit'
However there seems to be a difference in newer versions of ghostscript that causes this to fail:
GPL Ghostscript 10.00.0: Cannot open X display `(null)'.
**** Unable to open the initial device, quitting.
It seems that passing -dNODISPLAY to gs makes this issue go away, but that is not done by default.
Steps to Reproduce
Running the above command on older / newer versions of ghostscript.
Images
n/a
I suspect this must be related to the file that you are using or maybe even a change in their latest patches. I just pushed a patch to add the -dNODISPLAY in the native library because it does seem the right way to do this according to their documentation. There are unit tests on both Windows and Linux that use Ghostscript 10.0.0 so we should know what this change does after I upgrade the native library here.