Cannot use "convert" to generate a .gif from a .pdf

134 views Asked by At

I was looking into using tikz on latex to generate gifs, my example project is:

\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}

then after compiling as a pdf I ran the command

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

to generate the .gif, however I get the error

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

I'm using imagemagickk on windows: ImageMagick 7.1.1-21 Q16-HDRI x64 58d86e4:20231021 https://imagemagick.org

I've tried using full path names already as well.

1

There are 1 answers

0
K J On

There is nothing wrong with the convert command line here is the result from a PDF. However don't use a big file, one of mine is still running inside convert for the past half hour, each page is 2 files one is small (over 4000 x 10 KB) the other component is big (400 x 24 MB), and appears to be building at 60 pages per minute! So a single file of 4000s of pages from 2 MB PDF is going to be hours to convert, if at all!

If there is an error in requirements the result will always be the same as yours.
convert: no images defined `test.gif' @ error/convert.c/ConvertImageCommand/3362.

enter image description here

If there was no input file it should have previously errored with

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

In which case the fix is ensure a valid file and path are given.

If there is no GhostScript it should previously error with unable to run GhostScript. Here when converting to PNG first ON Windows32.

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.

In which case ensure installed and correctly on path, so for me that's, first run

path C:\Users\Name\Downloads\GS\10021\bin;%path%

HOWEVER

Currently you Tikz output needs to be altered to one page per image, (37 pages). Currently they are spread poorly on 3 pages (14+14+9). But that is a separate question suited to https://tex.stackexchange.com You may need to consider article class and page \geometry enter image description here