Código PHP:
<?php
Header( "Content-type: image/gif");
$total = "3"; // Numero total de imagenes
$carpeta = "/imagenesafi";
$random = mt_rand(1, $total);
$imagen = $random . ".gif";
$imagen_png = file_get_contents('$imagen');
echo " $imagen_png";
?>