RewriteEngine on

RewriteRule ([^.]+\.(jpe?g|gif|bmp|png))$ img.php?p=$1 [L,QSA] 
