I tend to agree with Rick on this.  I've got code like this throughout the media apps. Possibly you can create the just right abstraction to replace lots of that code with one shared utility function.  If you want to attempt that, though, I'd rename the function to getResizedImage() or something.  Or maybe one function (like this one) called getResizedImageAsBlob() that passes a blob to the callback.  And another one getResizedImageAsImage() that creates the blob url, waits for the onload callback and then passed the loaded <img> element to the callback.  Something like that would be useful here for the two places you call your function.