<?php

// where the images are stored
$directory = "./images";

// open the directory
$dir = opendir( $directory );

// loop through it, looking for any/all JPG files:
while (false !==...