Here is the MWE for pdfLaTeX, assuming that you have the command line convert from Image Magick installed, and using the .png route, as pdfLaTeX already has the method for PNG:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
% loading epstopdf package might be needed,
% but is often automatically loaded by graphicx when running pdfLaTeX
%\usepackage{epstopdf}
% epstopdf setup for GIF
\DeclareGraphicsRule{.gif}{png}{.png}{%
\noexpand\epstopdfcall{convert #1 \noexpand\OutputFile}%
}
\AppendGraphicsExtensions{.gif}
\begin{document}
\subsection{This is a GIF version}
\includegraphics[width=0.5\linewidth]{tmp.gif}
% The GIF file is converted to tmp-gif-converted-to.png
\subsection{This is a jpg version}
\includegraphics[width=0.5\linewidth]{tmp.jpg}
\subsection{This is a png version}
\includegraphics[width=0.5\linewidth]{tmp.png}
\subsection{This is a pdf version}
\includegraphics[width=0.5\linewidth]{tmp}
\end{document}

EDIT:
With old fashioned LaTeX (in dvi mode) one would have to convert GIFs to EPS.
For this purpose, one can replace the \DeclareGraphicsRule above by the following one:
\DeclareGraphicsRule{.gif}{eps}{.gif.bb}{`convert #1 eps:-}
Then the conversion command is written verbatim in the .dvi file, and executed by dvips provided it is run with the -R0 option. Finally the PDF file can be produced by using ps2pdf.
However, this method has several drawbacks:
- the converted figures are huge;
- it does not work with
dvipdfm(x).
- it works only if the
.gif.bb file has been created, that can be done with a command like:
identify tmp.gif |sed -r -e "s/(.*)\s+([0-9]{2,})x([0-9]{2,})\s+(.*)/%%BoundingBox: 0 0 \2 \3/" > tmp.gif.bb
for each graphic file tmp.gif.
In this context, it becomes much more efficient to write a batch to perform the conversion of all the files outside of LaTeX/dvips, by using convert with suitable options, or Netpbm, or Irfanview (windows only) and so on.
EDIT 2: On Windows, the convert command is a disk handling tool, and recent versions of ImageMagick use imagemagick convert (with the space) instead of the bare convert. Then \epstopdfcall must be modified accordingly.
\includegraphics[width=0.5\textwidth]{small.gif}. – Jhor Feb 21 '19 at 08:51\DeclareGraphicsRule{.JPG}{eps}{.JPG}{convert #1 eps:-}` into a gif version. – Jhor Feb 21 '19 at 09:01