I would like to use the externalize library. So far it worked perfectly and created pdf documents. But now I want to get a "png" file instead. I tried, according to the externalize documentation, the following:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize[prefix=,figure list=true]
\tikzset{
png export/.style={
% First we call ImageMagick; change settings to requirements
external/system call/.add={}{& magick.exe -density 300 "\image.pdf" "\image.png"},
% Now we force the PNG figure to be used instead of the PDF
/pgf/images/external info,
/pgf/images/include external/.code={
\includegraphics[width=\pgfexternalwidth,height=\pgfexternalheight]{##1.png}
},
}
}
\begin{document}
\tikzset{png export}
\tikzsetnextfilename{Figure-A}%
\begin{tikzpicture}
\draw (0,0) circle (2) ;
\end{tikzpicture}
\end{document}
This though does lead to an error in Windows 11 + MiKTeX Console 4.9 + TeXstudio 4.5.2 (git 4.5.2) + ImageMagick 7.1.1-5 Q16-HDRI x64 + lualatex (LuaHBTeX, Version 1.16.0 (MiKTeX 23.1)):
Process: lualatex.exe -synctex=1 -interaction=nonstopmode -shell-escape "main".tex
Meldung: "Der Befehl "magick.exe" ist entweder falsch geschrieben oder konnte nicht gefunden werden." (English it means: "The command "magick.exe" is either misspelled or could not be found.")
Log: "Package luatex.def Error: File `Figure-A.png' not found: using draft setting. \end{tikzpicture}"
The Figure-A.log file doesn't show any error so far as I can see, but the main.log file shows an error at this line:
\openout4 = main.figlist
Writing 'Figure-A' to 'main.figlist'.
\openout3 = Figure-A.md5
\openout3 = main.auxlock
===== 'mode=convert with system call': Invoking 'lualatex -shell-escape -halt-o
n-error -interaction=batchmode -jobname "Figure-A" "\def\tikzexternalrealjob{ma
in}\input{main}"& magick.exe -density 300 "Figure-A.pdf" "Figure-A.png"' ======
==
\openout3 = main.auxlock
LaTeX Warning: File `Figure-A.png' not found on input line 24.
! Package luatex.def Error: File `Figure-A.png' not found: using draft setting.
See the luatex.def package documentation for explanation.
Type H <return> for immediate help.
...
l.24 \end{tikzpicture}
Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.
Summary:
-) The Figure-A.pdf file has been created, but it seems there is a problem with the conversion from the "pdf" to "png" file.
-) If I run the process on the commandline instead of TeXStudio the same problem occurs.
-) When I try this on the command line 'magick.exe -density 300 "Figure-A.pdf" "Figure-A.png"' after one latex run (to generate Figure-A.pdf) it generates the image "Figure-A.png" perfectly.
-) I found out it works with pdflatex, so it seems to be a problem with lualatex. Although I don't know where the problem is and I would need it lualatex...
Would appreciate if someone could look into this and help me out.
.exe
file as it is not being found. Also double-check the name of the executable on your system.external/system call/.add={}{& "C:\\Program Files\\ImageMagick-7.1.1-Q16-HDRI\\magick.exe" -density 300 "\image.pdf" "\image.png"},
I don't really understand why I would need the full path (nor why I need the quotes) when I want to do it with lualatex, but as long as it does work... <3 Thanks.