Fix for
r87923, which made broken but harmless code from
r62223 actually start running and causing harm. $image is undefined and $length was unused. Merged from 1.18wmf1
r98207. This version does basically the same thing as the one in
r25467, except that width and height parameters have been added.