Unix command to make png series from gif pictures in a directory
# steeldriver, https://unix.stackexchange.com/a/370132/16920
find -L . -name '*.gif' -execdir sh -c 'for f;
do convert -coalesce "$f" "${f%.gif}%05d.png";
done' sh {} +
Pseudocode
Pass the info from
${f%.gif}%05dsomehow to LaTeX in one step.findmax filename series end and apply this to LaTeX file filename and iterate. Pseudocode to find the max series image count\usepackage{bashful} \bash[stdoutFile=gif_series.tex] find -L . -name '*.png' -execdir sh -c 'for f; ... TODO LaTeX + find max image count + apply it to LaTeX done ' sh {} + \END
Data files
Example list of gif filenames
/home/masi/Images/cautious2.gif /home/masi/Images/cautious.gifExample lists of png image series where the end number go max to 99
/home/masi/Images/cautious200000.png /home/masi/Images/cautious200001.png ... /home/masi/Images/cautious00000.png ...
LaTeX where I want to direct the image series on own pages where the filenames are now form out000xyzw
\documentclass{beamer}
\usepackage{bashful}
\usepackage{pgffor} % I think needed, but possibly not since Bash
\usepackage{animate}
\usepackage{graphicx}
\begin{document}
\begin{frame}
\begin{figure}
% TODO apply here Bashful somehow
% TODO something wrong here because the bash should be inserted here and not to a new file if the main script is compiled
\bash[stdoutFile=gif_series.tex]
% AlexG, https://tex.stackexchange.com/a/373780/13173
\animategraphics[
width=\textwidth,
controls,autoplay,loop
]{12}{out000}{00}{16} % TODO here {out000}{00}{16} for dynamics
\END
\end{figure}
\end{frame}
\end{document}
Testing TH.'s code
I had to do touch test.stdout test.stderr test.stoutwas for the script.
Output with facepalm1.gif and facepalm2.gif which yiels 0 pages with pdflatex code.tex and xelatex code.tex
r-environment-dictionary/translator-environment-dictionary-English.dict)
(/usr/local/texlive/2017/texmf-dist/tex/latex/beamer/translator/dicts/translato
r-months-dictionary/translator-months-dictionary-English.dict)
(/usr/local/texlive/2017/texmf-dist/tex/latex/beamer/translator/dicts/translato
r-numbers-dictionary/translator-numbers-dictionary-English.dict)
(/usr/local/texlive/2017/texmf-dist/tex/latex/beamer/translator/dicts/translato
r-theorem-dictionary/translator-theorem-dictionary-English.dict)
No file test.nav.
after EOF
(./test.stdout) (./test.aux) )
No pages of output.
Transcript written on test.log.
Output with pdflatex -shell-escape code.tex: correct!
Testing cfr second answer
Corrected working code with removal of ./anim to ./ and changed sh to bash (cfr)
\documentclass{beamer}
\usepackage{bashful,animate,pgffor}
\begin{document}
\bash
find . -name '*.gif' -execdir bash -c 'for i;
do
c=$(convert -coalesce -identify "$i" "${i/\.gif/.png}" | wc -l);
((c--));
printf \%b "$(basename ${i/\.gif/})/$c,";
done' bash {} + | sed 's/,$//'
\END
\begin{frame}
\centering
\foreach \i/\j in \bashStdout {\animategraphics[width=.2\linewidth,controls,autoplay,loop]{12}{\i-}{0}{\j} \\ }
\end{frame}
\end{document}
Files
masi@masi:~/Desktop/test.animate/anim$ ls
horna.gif horn.gif test2.log test2.sh
hornb.gif test2.aux test2.out test2.tex
Output after compilation with pdflatex -shell-escape test2.tex when sh there
(/usr/local/texlive/2017/texmf-dist/tex/latex/beamer/translator/dicts/translato
r-theorem-dictionary/translator-theorem-dictionary-English.dict)
No file test2.nav.
Standard error not empty. Here is how
file test2.stderr begins:
>>>>sh: 3: sh: Bad substitution
>>>>
but, you really ought to examine this file yourself!
! Your shell script failed....
\checkScriptErrors@BL ...r shell script failed...}
\BL@verbosetrue \logBL {Sw...
l.11 \END
?
L11: Switching to verbose mode
L11: Checking whether any listings are required
L11: Nothing has to be listed
L11: Defining macro for the contents of the standard output file
L11: Opened file test2.stdout
L11: Reading contents of test2.stdout
after EOF
L11: bashStdout :=
/0,/0,/0
L11: Closing file test2.stdout
L11: Defining macro for the contents of the standard error file
L11: Opened file test2.stderr
L11: Reading contents of test2.stderr
L11: bashStderr :=
sh: 3: sh: Bad substitution
L11: Closing file test2.stderr
L11: Wrap up done
L11: bashV: Done!
! Package animate Error: None of the files
(animate) `-0.pdf',
(animate) `-0.mps',
(animate) `-0.png',
(animate) `-0.jpg',
(animate) `-0.jpeg',
(animate) `-0.jbig2',
(animate) `-0.jb2',
(animate) `-0.jp2',
(animate) `-0.j2k' or
(animate) `-0.jpx',
(animate) could be found.
(animate) Wrong file type? Mis-spelled file name?.
See the animate package documentation for explanation.
Type H <return> for immediate help.
...
l.15 \end{frame}
Output with sh: no .gif animations in pdf, no pdf produced in Fig. 1
Fig. 1 cfr code output when sh used
test2.stderr content when sh used
sh: 3: sh: Bad substitution
sh: 4: sh: c--: not found
sh: 5: sh: Bad substitution
sh: 3: sh: Bad substitution
sh: 4: sh: c--: not found
sh: 5: sh: Bad substitution
sh: 3: sh: Bad substitution
sh: 4: sh: c--: not found
sh: 5: sh: Bad substitution
Solution: change the original sh parts to bash as proposed by cfr.
Output pdflatex -shell-escape test2.tex: correct!
OS: Debian 8.7
TexLive: 2017





bashrather thanshasshis evidently notbash. – cfr Jun 26 '17 at 11:18