<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.+)\.(jpg|png|jpeg)$ script.pl?name=$1&ext=$2 [L,QSA]
</IfModule>