Open Krastanov opened 3 years ago
So, Ghostscript is now packaged https://juliahub.com/ui/Packages/Ghostscript_jll/A26Vb/9.53.3+0
convert
works on Linux and Mac, but not on Windows. There is an issue with path finding for some of the configuration files.
To perform a conversion one needs both gs
and convert
in their PATH:
gs() do gsbin
imagemagick_convert() do bin
run(`$bin input.pdf output.png`)
end
end
However, on Windows the following exception arises inside of convert:
convert.exe: UnableToOpenConfigureFile `delegates.xml' @ warning/configure.c/GetConfigureOptions/712.
convert.exe: FailedToExecuteCommand `"gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r500x500" "-sOutputFile=C:/Users/RUNNER~1/AppData/Local/Temp/magick-2484CLvqAlSS92c3%d" "-fC:/Users/RUNNER~1/AppData/Local/Temp/magick-2484DuTJpe1QBI6D" "-fC:/Users/RUNNER~1/AppData/Local/Temp/magick-2484Jerj24FzP5tM"' (The system cannot find the file specified.
) @ error/delegate.c/ExternalDelegateCommand/459.
convert.exe: PDFDelegateFailed `The system cannot find the file specified.
' @ error/pdf.c/ReadPDFImage/811.
I think this is a problem with the ImageMagick_jll
package, but I am not quite certain.
Here are test runs that show this code running on Linux and Mac, but not on Windows: https://github.com/Krastanov/Quantikz/runs/2048488216
Any insight and suggestions on where to debug would be greatly appreciated! Is this as simple as adding Ghostscript_jll
as a dependency to ImageMagick_jll
? I do not have a Windows machine so it is rather difficult for me to run tests.
I am now using FileIO
to convert between pdf and png, without having to explicitly depend on Ghostscript_jll and ImageMagick_jll.
Hence, maybe this issue should be closed? I will let the maintainers decide whether to close this and whether it is worth looking into Ghostscript_jll for other purposes.
Sigh, I was wrong in the above comment. The only reason FileIO worked was because I have ghostscript installed on my local machine. CI tests still fail. Ghostscript_jll solves this for Linux and Mac, but I am still open to suggestions for how to do it on Windows.
Here is a simplified version of the bug report:
load("file.pdf")
does not work without ghostscript installed on the system.
However, with Ghostscript_jll
this works:
using Ghostscript_jll
gs() do bin # adds gs to the PATH
load("file.pdf")
end
The issue is that it works only on Mac and Linux. On Windows, the convert.exe command fails to find the delegate file (as shown in the detailed error message in a previous comment). This can also be seen in these CI logs https://github.com/Krastanov/Quantikz/runs/2048843301
I was able to run convert -debug configure input.pdf output.png
on the Windows CI and it seems part of the problem might be that some of the required configuration files in ImageMagick_jll
are placed in the wrong location on Windows.
convert.exe
looks for the file in C:\Users\runneradmin\.julia\artifacts\617bbb3e9d12da4f4910335239ea94e523ebd4aa\bin\delegates.xml
while the file is actually in ...\etc
. But at the end it seems it just runs with some default built-in assumption even if the file is not found. Then, when gs
is being invoked inside of convert
the command crashes.
Here is the CI log for
gs() do bin
imagemagick_convert() do convert
run(`$convert -debug configure input.pdf out.png`)
end
end
https://github.com/Krastanov/Quantikz/pull/1/checks?check_run_id=2049224946
A workaround might be to stop worrying about ImageMagick_jll and just use Ghostscript_jll directly when converting a pdf to other formats (ImageMagick does not really do anything here anyway https://stackoverflow.com/a/36137513 ).
Edit: Ghostscript is now packaged and
convert file.pdf file.png
works on most platforms.Original Message:
I was pleased to see that
convert
fromImageMagic_jll
is so easy to use from inside of Julia. However, for converting pdf to png, it shells out togs
. I am attempting to packagegs
withBinaryBuilder
. I am a novice into this and given thatgs
would be of use to this package, I was hoping someone could help me with fleshing out the various issues with thegs
package. Here is a link to the currentbuild_tarballs
pull request: https://github.com/JuliaPackaging/Yggdrasil/pull/2646