无法使用“转换”从 .pdf 生成 .gif

问题描述 投票:0回答:1

我正在研究在 Latex 上使用 tikz 来生成 gif,我的示例项目是:

\documentclass[]{report}
\usepackage{tikz}
\begin{document}
\foreach \angle in {0,10,...,360}
{
  \begin{tikzpicture}
    % fill circle and plot
    \fill[blue!50] (-1,0) arc (0:\angle:1) -- (-2,0) -- cycle;
    \fill[blue!50] plot[smooth,domain=0:\angle] (pi/180*\x,{sin(\x)}) |- (0,0);
    % draw connection
    \draw (-2,0) +(\angle:1) circle (2pt) -- (pi/180*\angle,{sin(\angle)}) circle (2pt);
    % draw axes an ticks
    \draw (-3.5,0) -- (7,0);
    \foreach \deg in {90, 180, 270, 360}
      \draw (pi/180*\deg,2pt) -- (pi/180*\deg,-2pt) node[below] {$\deg^\circ$};
    \draw (0,-1.2) -- (0,1.2);
    \foreach \y in {-1,-0.5,0.5,1}
      \draw (2pt,\y) -- (-2pt,\y) node[left] {$\y$};
    % draw plot and circle outline
    \draw plot[smooth,domain=0:360] (pi/180*\x,{sin(\x)});
    \draw (-2,0) circle (1);
  \end{tikzpicture}
}
\end{document}

然后编译为 pdf 后我运行命令

convert -density 300 -delay 8 -loop 0 -background white -alpha remove test.pdf test.gif

生成 .gif,但是我收到错误

convert.exe: no images defined 
test.gif'@error/convert.c/ConvertImageCommand/3362`

我在 Windows 上使用 imagemagickk:ImageMagick 7.1.1-21 Q16-HDRI x64 58d86e4:20231021 https://imagemagick.org

我也已经尝试过使用完整路径名。

imagemagick-convert tex-live
1个回答
0
投票

这里的转换命令行没有任何问题,是来自a PDF的结果。但是,不要使用大文件,我的一个文件在过去的半小时内仍在转换中运行,每个页面有 2 个文件,一个文件较小(超过 4000 x 10 KB),另一个组件较大(400 x 24 MB),似乎正在以每分钟 60 页的速度构建!因此,如果需要转换 2 MB PDF 中 4000 页的单个文件,则需要几个小时才能转换!

如果要求有错误,结果将始终与您的相同。
转换:没有定义图像“test.gif”@ error/convert.c/ConvertImageCommand/3362。

如果没有输入文件,它之前应该会出错

convert: unable to open image 'test.pdf': No such file or directory @ error/blob.c/OpenBlob/3573.

在这种情况下,修复方法是确保给出有效的文件和路径。

如果没有 GhostScript,之前应该会出现无法运行 GhostScript 的错误。这里是在 Windows32 上首先转换为 PNG 时的情况。

convert: FailedToExecuteCommand `"gswin32c.exe" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r300x300" -dPrinted=false  "-sOutputFile=C:/Users/lez/AppData/Local/Temp/magick-O97aXP6WKrz88Cs64Sls2m1S27fB44yY%d" "-fC:/Users/lez/AppData/Local/Temp/magick-NbsR9bfQaWYriIlKptLnhozpdT856u-L" "-fC:/Users/lez/AppData/Local/Temp/magick-AvLZH_aCPiTXmJax3Wo5pnBFkil0oYd3"' (The system cannot find the file specified.
) @ error/delegate.c/ExternalDelegateCommand/519.
convert: PDFDelegateFailed `The system cannot find the file specified.
' @ error/pdf.c/ReadPDFImage/712.

在这种情况下,请确保安装并正确安装在路径上,所以对我来说,首先运行

path C:\Users\Name\Downloads\GS\10021\bin;%path%
© www.soinside.com 2019 - 2024. All rights reserved.