Regexp is very powerful. Here's the breakdown of that pattern:
@ - appears on both ends, this is the delimiter I chose. Commonly you'll see a forward slash used, but since I wanted to use a forward slash in the query (in case you're XHTML complient and use "<img />" tags), I had two basic options: 1) Escape the slash in the pattern (e.g. "\/") or simply use a different delimiter. I obviously chose the latter route.
(<img\s+) - Surrounding something in parenthesis means you're grouping what's in between the parenthesis so you can use it later. This is where the $1, $2, and $3 come from - if you'll notice, there's three basic "groups" in my pattern, defined by parenthesis. In this group, I'm saying "Find <img followed by 1 or more spaces.
(.?) - Here's the meat of what we want. '.' means any character, '' means 0 or more times, and the '?' following a + or * changes the modifier to be "nongreedy." Basically, it tells it to stop as soon as it sees something that matches the next part of the pattern.
(\s+/?>) - Again, \s is a whitespace character, so \s+ means "one or more spaces". The /? means that the '/' can appear zero or one times. Basically, if you put a ? after a character, it makes it optional. And the '>' of course comes from the end of the IMG tag.
After the last delimiter, you see three other modifiers: i, s, e. 'i' makes the pattern case-insensitive, 's' is a "dot-all" modifier, meaning that the '.' matches any character including line breaks; by default a '.' will not match line breaks, and the 'e' means that the replacement string should be treated as if it were run through the [man]eval/man function, running it as PHP code instead of taking it as a literal string -- this is how you can use functions in conjunction with preg_replace().
As for the replacement, you'll see that i'm leaving the $1 and $3 groups untouched - this is the <img and > part of the tag. The $2 group, where the attributes are grouped, are run through the resizeImage() function; this function's return value is concatenated in between the two groups to form your new image tag.
Now, after explaining my pattern, here's some improvements I noticed:
$pattern = '@(<img\s+)(.+?)(\s*/?>)@ise';
Basically, I just changed the * to a + in the second group since we want to match something, and I changed the + to a * in the third group because there isn't always whitespace between the last attribute and the closing '>' tag.
EDIT: A very good website for regular expressions can be found here. I have found this site to be quite useful; the 'tutorial' link on the left explains many of the features regular expressions has to offer.