Great notes on this blog: How to create GIFs with FFmpeg
Rename all of the target images to have a sequential naming scheme.
a=1; for i in *.png; do new=$(printf "%04d.png" "$a"); mv -i -- "$i" "$new"; let a=a+1; done
convert -delay 10 -loop 0 *.png output.gif
ffmpeg -i %04d.png output.gif
magick -density 600 file.pdf file_frame%02d.png
magick -delay 50 -loop 0 file_frame*.png out.gif
When there are a large amount of high quality images, it mya be more efficient to create a video instead.