Actually the code is a very simple parser located in:
\Sublime Text 2\Packages\ZenCoding\zencoding\utils.py:
yeah, but what's a "stream"? then you go further down the rabbit hole when you go looking for zen_file.read() and then you start looking at all the excellent code in zen that has to do with identifying when you are in the img tag and how to create / update the height and width attributes, ...and then... at least if you're me (yes, lazy), you conclude that it might be easier to try to just call the zen coding update_image_size action than try to extract all the relevant code or call the bits and pieces of it from within AutoFileName.
but when i started going down that path, i found that there seems to be no call-back or event listener that lets you know when a completion has been inserted into the document, so that path is probably moot, and we're back to trying to extract all the bits and pieces from zen coding. which, you're right i guess, might not be so bad... zen_file.read is just a simple python file.read()