I wouldn't recommend dynamically creating a NEW image, EVERY single time someone loads a page, for EVERY single image... That's INCREDIBLY inefficient, and on a website with traffic, it is very taxing.
It is much more efficient to make a script to simply generate a thumbnail for all your images, then display the static thumbnail. Generating the resized image on the fly does not save the end-user any bandwidth / download times, either. They still have two separate files they download, as technically your original and thumbnail are still two different images.
If you do want to use a script to link to in your image tags, make your script check a thumbnail directory for the image. If it exists, display it. If not, generate it, then throw it into the thumbnail directory as well. Leaving the script you linked in its current state is a bad idea, though. It works, and for a small website will be fine, but for a website with traffic you will want to reduce the amount of real-time dynamics as much as -possible. At the very least, with caching. Don't make your users suffer because you don't want to take the time to do it RIGHT and efficient. The less you do in your scripts, the more your users have to do / wait.