I see. Can we draw the image into a canvas, call toDataURL and set that in the style? I think that would be more maintainable. Alternatively, we could probably use SVG.

Though I'm still not sure anyone other than the author could tell things were working correctly by eye.