PDF to image conversions crash the process: Unrecoverable error: rangecheck in setscreen (MagickDelegateError)
PDF → image conversions crash the process: "Unrecoverable error: rangecheck in setscreen" (MagickDelegateError)
Describe the bug
Any PDF → image conversion (e.g. To Jpg, To Png (paged)) crashes File Converter on v2.2 (also reproduced on v2.1). The main window opens, but the conversion never starts; the process dies silently with no error in the diagnostics log (which stops at Show page Main.). Windows Error Reporting records AppCrash_FileConverter.exe with exception ImageMagick.MagickDelegateError (faulting module Magick.NET-Q16-AnyCPU, version 14.10.2.0).
No output files are produced.
To reproduce
- Right-click any PDF → Convert to →
To Jpg - The main page opens, then the process crashes / exits without producing any JPG
Root cause analysis
Analysis, reproduction and fix design were performed by a DeepSeek AI assistant; the user only executed the installation/verification steps per the assistant's instructions.
ConversionJob_ImageMagick.GetOutputFilesCount()reads the PDF withDensity(1, 1)to count pages. ImageMagick's PDF delegate then invokes Ghostscript with-r1x1. At 1 dpi, Ghostscript aborts with:Unrecoverable error: rangecheck in setscreen Operand stack: 0.0624961 0 --nostringval--This reproduces on Ghostscript 10.02.1 and 10.07.1, in both subprocess (
gswin64c.exe) and library (SetGhostscriptDirectory→ gsdll64.dll) modes.GetOutputFilesCount()runs beforeInitialize()inPrepareConversion(), i.e. beforeMagickNET.SetGhostscriptDirectory(...)is called, so the delegate relies on whatever Ghostscript it can auto-detect (PATH / registry). On machines without a system-wide Ghostscript install the delegate fails with exit code 127 (FailedToExecuteCommand "gswin64c.exe").Non-ASCII username: on systems with a Chinese username (e.g.
C:\Users\苦寒来), the delegate subprocess receives mangled temp paths (the non-ASCII characters are replaced with underscores), so Ghostscript cannot find its input files and exits with code 1.
Suggested fix
- In
GetOutputFilesCount(), use a sane density for the page-count probe instead ofDensity(1, 1)(e.g. 72 dpi), or skip rendering entirely (e.g. usePingwhere possible). - Call
MagickNET.SetGhostscriptDirectory(...)before the page-count read. - Use an ASCII-safe temp directory for the delegate files on systems with non-ASCII usernames.
Workaround (verified end-to-end on this machine)
- Install Ghostscript (10.07.1) and add it to PATH
- Place a
gswin64c.exewrapper earlier in PATH that rewrites-r1x1→-r72x72(bypasses the setscreen crash) - Remove the
GS_DLLregistry value (HKLM\SOFTWARE\GPL Ghostscript\<ver>) so Magick.NET uses the subprocess delegate (where the wrapper applies) - Set
MAGICK_TEMPORARY_PATHto an ASCII-only directory (avoids the mangled-path issue)
Environment
- OS: Windows 10 Pro 19045 (x64)
- File Converter: 2.2.0.0 (also reproduced with 2.1.0.0)
- Magick.NET: 14.10.2 (v2.2) / 14.4.0 (v2.1)
- Ghostscript: 10.02.1 (bundled) / 10.07.1 (system)
Source: Tichau/FileConverter